Repository: karaf
Updated Branches:
  refs/heads/master e4469dca2 -> 56eccaaf9


[KARAF-4834] Infinite loop in console if an I/O exception is thrown by the 
input stream

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/56eccaaf
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/56eccaaf
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/56eccaaf

Branch: refs/heads/master
Commit: 56eccaaf95b8e3cd81f9fabbf4322abdf8f427aa
Parents: e4469dc
Author: Guillaume Nodet <gno...@apache.org>
Authored: Thu Dec 1 12:01:45 2016 +0100
Committer: Guillaume Nodet <gno...@apache.org>
Committed: Thu Dec 1 12:01:45 2016 +0100

----------------------------------------------------------------------
 .../shell/impl/console/ConsoleSessionImpl.java  | 29 ++++++++++----------
 1 file changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/56eccaaf/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
----------------------------------------------------------------------
diff --git 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index 22d2a1e..5dc793e 100644
--- 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -328,25 +328,26 @@ public class ConsoleSessionImpl implements Session {
             String scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
             executeScript(scriptFileName);
             while (running) {
+                String command = null;
+                reading.set(true);
+                try {
+                    command = reader.readLine(getPrompt(), getRPrompt(), null, 
null);
+                } catch (UserInterruptException e) {
+                    // Ignore, loop again
+                    continue;
+                } catch (Throwable t) {
+                    ShellUtil.logException(this, t);
+                } finally {
+                    reading.set(false);
+                }
+                if (command == null) {
+                    break;
+                }
                 try {
-                    reading.set(true);
-                    String command;
-                    try {
-                        command = reader.readLine(getPrompt(), getRPrompt(), 
null, null);
-                    } finally {
-                        reading.set(false);
-                    }
-                    if (command == null) {
-                        break;
-                    }
                     Object result = session.execute(command);
                     if (result != null) {
                         session.getConsole().println(session.format(result, 
Converter.INSPECT));
                     }
-                } catch (UserInterruptException e) {
-                    // Ignore, loop again
-                } catch (EndOfFileException e) {
-                    break;
                 } catch (Throwable t) {
                     ShellUtil.logException(this, t);
                 }

Reply via email to