You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2017/09/14 14:53:16 UTC

karaf git commit: Catch exceptions while parsing the command line in the masking callback

Repository: karaf
Updated Branches:
  refs/heads/master 1103f3de2 -> 4dbc729f0


Catch exceptions while parsing the command line in the masking callback

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

Branch: refs/heads/master
Commit: 4dbc729f016fd1c54c5db02526eac5cc10d82528
Parents: 1103f3d
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Sep 14 16:53:10 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Sep 14 16:53:10 2017 +0200

----------------------------------------------------------------------
 .../shell/impl/console/ConsoleSessionImpl.java     | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4dbc729f/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 1c3f2a9..2151e11 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
@@ -71,6 +71,7 @@ import org.jline.reader.LineReader;
 import org.jline.reader.LineReaderBuilder;
 import org.jline.reader.MaskingCallback;
 import org.jline.reader.ParsedLine;
+import org.jline.reader.SyntaxError;
 import org.jline.reader.UserInterruptException;
 import org.jline.terminal.Terminal.Signal;
 import org.jline.terminal.impl.DumbTerminal;
@@ -664,11 +665,17 @@ public class ConsoleSessionImpl implements Session {
                     this.regexs.putAll(regexs);
                 }
             }
-            ParsedLine pl = reader.getParser().parse(line, line.length());
-            String cmd = resolveCommand(pl.words().get(0));
-            ActionMaskingCallback repl = regexs.get(cmd);
-            if (repl != null) {
-                line = repl.filter(line, pl);
+            try {
+                ParsedLine pl = reader.getParser().parse(line, line.length());
+                String cmd = resolveCommand(pl.words().get(0));
+                ActionMaskingCallback repl = regexs.get(cmd);
+                if (repl != null) {
+                    line = repl.filter(line, pl);
+                }
+            } catch (SyntaxError e) {
+                // Ignore
+            } catch (Exception e) {
+                LOGGER.debug("Exception caught while masking command line", e);
             }
             return line;
         }