summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-05-21 16:12:28 -0500
committerInstrumental <jonathan.gathman@att.com>2018-05-21 16:13:29 -0500
commit8c6365116711469c74436141d63f046ef88b9023 (patch)
treee8f01cdfe8ad75206f7c4e2cb2663af5cb958cdc
parentdf1d564a24b1bd9afb3a912f7389992826aa8677 (diff)
Fix SubStandardConsole
Issue-ID: AAF-237 Change-Id: Ia4d446f95647be3cb03af1fbdc9f5d6b9f3d224b Signed-off-by: Instrumental <jonathan.gathman@att.com>
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java
index 8d528119..b7dd0148 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/SubStandardConsole.java
@@ -27,7 +27,13 @@ import java.io.InputStreamReader;
// Substandard, because System.in doesn't do Passwords..
public class SubStandardConsole implements MyConsole {
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ private final static char[] BLANK = new char[0];
+ private final BufferedReader br;
+
+ public SubStandardConsole() {
+ br = new BufferedReader(new InputStreamReader(System.in));
+ }
+
@Override
public String readLine(String fmt, Object... args) {
String rv;
@@ -48,10 +54,12 @@ public class SubStandardConsole implements MyConsole {
public char[] readPassword(String fmt, Object... args) {
try {
System.out.printf(fmt,args);
- return br.readLine().toCharArray();
+ String response = br.readLine();
+ return response==null?BLANK:response.toCharArray();
+
} catch (IOException e) {
System.err.println("uh oh...");
- return new char[0];
+ return BLANK;
}
}