From ef8f992ca207281c6a9dc5825107e8a9dfaac6e9 Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Thu, 23 Feb 2017 12:22:50 -0600 Subject: [PATCH] ARTEMIS-991 handle odd password input --- .../activemq/artemis/cli/commands/InputAbstract.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java index ec76255344..4d1fe356cb 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InputAbstract.java @@ -100,13 +100,21 @@ public class InputAbstract extends ActionAbstract { return silentDefault; } - String inputStr; + String inputStr = ""; boolean valid = false; System.out.println(); do { context.out.println(propertyName + ": is mandatory with this configuration:"); context.out.println(prompt); - inputStr = new String(System.console().readPassword()); + char[] chars = System.console().readPassword(); + + // could be null if the user input something weird like Ctrl-d + if (chars == null) { + System.out.println("Invalid Entry!"); + continue; + } + + inputStr = new String(chars); if (inputStr.trim().equals("")) { System.out.println("Invalid Entry!");