Use System.out for printing to console 43/76243/8
authorLoshmitha <loshmitha@ericsson.com>
Wed, 19 Sep 2018 09:49:33 +0000 (15:19 +0530)
committerSam Hague <shague@redhat.com>
Tue, 2 Oct 2018 21:31:18 +0000 (21:31 +0000)
Options to print to the console are not compatible so replacing them
with System.out

JIRA: NETVIRT-1436
Change-Id: I845f8fb422ba5478deec66abe1d3b8896f56c8b7
Signed-off-by: Loshmitha <loshmitha@ericsson.com>
bgpmanager/impl/src/main/java/org/opendaylight/netvirt/bgpmanager/DisplayBgpConfigCli.java
bgpmanager/impl/src/main/java/org/opendaylight/netvirt/bgpmanager/VtyshCli.java
bgpmanager/impl/src/main/java/org/opendaylight/netvirt/bgpmanager/commands/Cache.java

index 05c89622d124c23a79e211118db63364088e95c0..9587312c7ebc0b5b9466118a895482d36cabbe61 100644 (file)
@@ -32,9 +32,10 @@ public class DisplayBgpConfigCli extends OsgiCommandSupport {
         this.bgpConfigurationManager = bgpConfigurationManager;
     }
 
+    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
     @Override
     protected Object doExecute() {
-        PrintStream ps = session.getConsole();
+        PrintStream ps = System.out;
 
         if (debug) {
             ps.printf("%nis ODL Connected to Q-BGP: %s%n", bgpConfigurationManager.isBgpConnected() ? "TRUE" : "FALSE");
index 8f468ee95a1248cc70bb959d2262543d6691d15d..7025886e3438d01b4b80c8081a7ee0f9d55738ec 100644 (file)
@@ -115,6 +115,7 @@ public class VtyshCli extends OsgiCommandSupport {
         return serverName;
     }
 
+    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
     public void handleCommand(String command) throws IOException {
         char[] cbuf = new char[10];
         Socket socket;
@@ -133,10 +134,10 @@ public class VtyshCli extends OsgiCommandSupport {
             socket = new Socket(serverName, SERVER_PORT);
 
         } catch (UnknownHostException ioe) {
-            session.getConsole().println("No host exists: " + ioe.getMessage());
+            System.out.println("No host exists: " + ioe.getMessage());
             return;
         } catch (IOException ioe) {
-            session.getConsole().println("I/O error occured " + ioe.getMessage());
+            System.out.println("I/O error occured " + ioe.getMessage());
             return;
         }
         try {
@@ -145,7 +146,7 @@ public class VtyshCli extends OsgiCommandSupport {
             inFromSocket = new BufferedReader(new InputStreamReader(socket.getInputStream()));
 
         } catch (IOException ioe) {
-            session.getConsole().println("IOException thrown.");
+            System.out.println("IOException thrown.");
             socket.close();
             return;
         }
@@ -154,12 +155,12 @@ public class VtyshCli extends OsgiCommandSupport {
                 ret = inFromSocket.read(cbuf);
 
             } catch (SocketTimeoutException ste) {
-                session.getConsole().println("Read from Socket timed Out while asking for password.");
+                System.out.println("Read from Socket timed Out while asking for password.");
                 socket.close();
                 return;
             }
             if (ret == -1) {
-                session.getConsole().println("Connection closed by BGPd.");
+                System.out.println("Connection closed by BGPd.");
                 socket.close();
                 return;
             } else {
@@ -178,8 +179,8 @@ public class VtyshCli extends OsgiCommandSupport {
             try {
                 ip = inFromSocket.read();
             } catch (SocketTimeoutException ste) {
-                session.getConsole().println(sb.toString());
-                session.getConsole().println("Read from Socket timed Out while verifying the password.");
+                System.out.println(sb.toString());
+                System.out.println("Read from Socket timed Out while verifying the password.");
                 socket.close();
                 return;
             }
@@ -191,8 +192,8 @@ public class VtyshCli extends OsgiCommandSupport {
                 }
                 break;
             } else if (ip == -1) {
-                session.getConsole().println(sb.toString());
-                session.getConsole().println("Connection closed by BGPd.");
+                System.out.println(sb.toString());
+                System.out.println("Connection closed by BGPd.");
                 socket.close();
                 return;
             } else {
@@ -209,16 +210,16 @@ public class VtyshCli extends OsgiCommandSupport {
             try {
                 ip = inFromSocket.read();
             } catch (SocketTimeoutException ste) {
-                session.getConsole().println(sb.toString());
-                session.getConsole().println("Read from Socket timed Out while sending the term len command..");
+                System.out.println(sb.toString());
+                System.out.println("Read from Socket timed Out while sending the term len command..");
                 socket.close();
                 return;
             }
             if (ip == gt || ip == hashChar) {
                 break;
             } else if (ip == -1) {
-                session.getConsole().println(sb.toString());
-                session.getConsole().println("Connection closed by BGPd.");
+                System.out.println(sb.toString());
+                System.out.println("Connection closed by BGPd.");
                 socket.close();
                 return;
             } else {
@@ -272,9 +273,9 @@ public class VtyshCli extends OsgiCommandSupport {
             }
             temp.setLength(0);
         }
-        session.getConsole().println(output.toString().trim());
+        System.out.println(output.toString().trim());
         if (errorMsg.length() > 0) {
-            session.getConsole().println(errorMsg);
+            System.out.println(errorMsg);
         }
         socket.close();
     }
index 751db956a4eb2b155a3b3f4214684263ae1beebf..2d41bc02ece62c2cb81079d7cfb647e01f91872b 100644 (file)
@@ -92,13 +92,12 @@ public class Cache extends OsgiCommandSupport {
         return doExecute();
     }
 
-    @SuppressWarnings("resource")
+    @SuppressWarnings({"resource", "checkstyle:RegexpSinglelineJava"})
     @Override
     protected Object doExecute() {
         boolean listVrfs = false;
         boolean listNets = false;
-        PrintStream ps = session.getConsole();
-
+        PrintStream ps = System.out;
         if (action != null) {
             return usage();
         }
@@ -109,7 +108,7 @@ public class Cache extends OsgiCommandSupport {
                 fileStream = new PrintStream(ofile);
                 ps = fileStream;
             } catch (FileNotFoundException e) {
-                session.getConsole().println("error: cannot create file " + ofile + "; exception: " + e);
+                System.out.println("error: cannot create file " + ofile + "; exception: " + e);
                 return null;
             }
         }
@@ -123,7 +122,7 @@ public class Cache extends OsgiCommandSupport {
                         listNets = true;
                         break;
                     default:
-                        session.getConsole().println("error: unknown value for " + LST + ": " + item);
+                        System.out.println("error: unknown value for " + LST + ": " + item);
                         if (fileStream != null) {
                             fileStream.close();
                         }