Merge "Sonar- AAF AUTH BATCH"
[aaf/authz.git] / auth / auth-cmd / src / main / java / org / onap / aaf / auth / cmd / AAFcli.java
index 2fbfa37..6ca37c3 100644 (file)
@@ -124,10 +124,10 @@ public class AAFcli {
     }
 
     public AuthzEnv env() {
-               return env;
-       }
+        return env;
+    }
 
-       public static int timeout() {
+    public static int timeout() {
         return TIMEOUT;
     }
 
@@ -250,7 +250,13 @@ public class AAFcli {
                     pw.println("Press <Return> to continue...");
                     ++idx;
                     // Sonar insists we do something with the string, though it's only a pause.  Not very helpful...
-                    String sonar = new BufferedReader(new InputStreamReader(System.in)).readLine();
+                    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+                    String sonar;
+                    try {
+                        sonar = br.readLine();
+                    } finally {
+                        br.close();
+                    }
                     sonar=""; // this useless code brought to you by Sonar.
                     pw.print(sonar);
                     continue;
@@ -332,7 +338,7 @@ public class AAFcli {
                             Thread.sleep((long)(delay+globalDelay));
                         }
                     } catch (Exception e) {
-                       if (expect.contains(-1)) {
+                        if (expect.contains(-1)) {
                             pw.println(e.getMessage());
                             ret = -1;
                         } else {
@@ -341,7 +347,7 @@ public class AAFcli {
                     } finally {
                         clearSingleLineProperties();
                     }
-                    rv = expect.isEmpty() ? true : expect.contains(ret);
+                    rv = expect.isEmpty() || expect.contains(ret);
                     if (verbose) {
                         if (rv) {
                             pw.println();
@@ -569,12 +575,16 @@ public class AAFcli {
                                 }
                             } else if (rdr != null) {
                                 BufferedReader br = new BufferedReader(rdr);
-                                String line;
-                                while ((line = br.readLine()) != null) {
-                                    if (!aafcli.eval(line) && exitOnFailure) {
-                                        rv = 1;
-                                        break;
+                                try {
+                                    String line;
+                                    while ((line = br.readLine()) != null) {
+                                        if (!aafcli.eval(line) && exitOnFailure) {
+                                            rv = 1;
+                                            break;
+                                        }
                                     }
+                                } finally {
+                                    br.close();
                                 }
                             } else { // just run the command line
                                 aafcli.verbose(false);