From da107f0a40955f13c0e3ba3f710b77843df9fb58 Mon Sep 17 00:00:00 2001 From: Emmanuel Bigeon Date: Fri, 12 Nov 2021 10:06:48 +0100 Subject: [PATCH] [doc] Added comments on a brain overloading method. Signed-off-by: Emmanuel Bigeon --- .../gclc/process/io/ConnectingConsoleInput.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gclc-process/src/main/java/net/bigeon/gclc/process/io/ConnectingConsoleInput.java b/gclc-process/src/main/java/net/bigeon/gclc/process/io/ConnectingConsoleInput.java index d6d8fc7..d91e7ca 100644 --- a/gclc-process/src/main/java/net/bigeon/gclc/process/io/ConnectingConsoleInput.java +++ b/gclc-process/src/main/java/net/bigeon/gclc/process/io/ConnectingConsoleInput.java @@ -206,10 +206,18 @@ public final class ConnectingConsoleInput implements ConsoleInput { return doPrompt(message, timeout, tic); } + /** Actually do the prompting + * + * @param message the prompt message + * @param timeout the time to wait for an answer + * @param tic the moment the wait started + * @return the message provided through the prompting + * @throws IOException if an IO error occurred while prompting. */ private String doPrompt(final String message, final long timeout, final long tic) throws IOException { do { if (!checkPrompt()) { + // We are not prompting... lets stop here. break; } getConnection(getTimeoutLeft(tic, timeout)); @@ -220,10 +228,13 @@ public final class ConnectingConsoleInput implements ConsoleInput { actualConnected = connected; } if (!connect) { + // There is no provide of input... So lets start again, until we actually + // DO get a provider of input. continue; } try { final String res = actualPrompt(message, timeout, tic, actualConnected); + // We got something from the prompting synchronized (promptLock) { if (prompting) { prompting = false;