karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch master updated: [KARAF-6258] Do not print error for user interrupted script
Date Sun, 05 May 2019 11:23:15 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/master by this push:
     new 998ca25  [KARAF-6258] Do not print error for user interrupted script
     new dc5493a  Merge pull request #822 from lkiesow/karaf-6258-init-script-interrupt
998ca25 is described below

commit 998ca25ee429235dbcd9feb9a4e7805ce4ca4cd9
Author: Lars Kiesow <lkiesow@uos.de>
AuthorDate: Fri Apr 26 20:52:10 2019 +0200

    [KARAF-6258] Do not print error for user interrupted script
    
    Karaf allows for the usage of commands like `log:tail` in
    `etc/shell.init.script` which is handy for example for a development
    assembly. But if such a command is canceled by a user (e.g. by hitting
    Ctrl+C) an error message is logged and printed to stderr, claiming an
    error in the initialization script.
    
    While keeping the debug logging, this patch suppresses the stderr
    message on user interrupts.
---
 .../org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java     | 5 +++--
 .../ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java  | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

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 49069e7..2561be1 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
@@ -70,7 +70,6 @@ import org.jline.reader.*;
 import org.jline.terminal.Size;
 import org.jline.terminal.Terminal.Signal;
 import org.jline.terminal.impl.DumbTerminal;
-import org.osgi.service.event.EventAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -578,7 +577,9 @@ public class ConsoleSessionImpl implements Session {
             session.execute(script);
         } catch (Exception e) {
             LOGGER.debug("Error in initialization script {}", scriptFileName, e);
-            System.err.println("Error in initialization script: " + scriptFileName + ": "
+ e.getMessage());
+            if (!(e instanceof InterruptedException)) {
+                System.err.println("Error in initialization script: " + scriptFileName +
": " + e.getMessage());
+            }
         } finally {
             session.put("script", oldScript);
         }
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
index 476efda..d72a278 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
@@ -151,7 +151,7 @@ public class ShellCommand implements Command, SessionAware {
     }
 
     public void destroy() {
-	}
+    }
 
     private void executeScript(String names, Session session) {
         FilesStream.stream(names).forEach(p -> doExecuteScript(session, p));
@@ -164,7 +164,9 @@ public class ShellCommand implements Command, SessionAware {
             session.execute(script);
         } catch (Exception e) {
             LOGGER.debug("Error in initialization script {}", scriptFileName, e);
-            System.err.println("Error in initialization script: " + scriptFileName + ": "
+ e.getMessage());
+            if (!(e instanceof InterruptedException)) {
+                System.err.println("Error in initialization script: " + scriptFileName +
": " + e.getMessage());
+            }
         }
     }
 


Mime
View raw message