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 2015/04/16 11:23:09 UTC

karaf git commit: [KARAF-3656] SSH message channel closed too early

Repository: karaf
Updated Branches:
  refs/heads/master 06165c91c -> 6cf9a4d29


[KARAF-3656] SSH message channel closed too early

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

Branch: refs/heads/master
Commit: 6cf9a4d29f1698f14d2eed06cd728d31c9e7870c
Parents: 06165c9
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Apr 16 11:11:35 2015 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Apr 16 11:11:35 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/karaf/shell/ssh/ShellCommand.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/6cf9a4d2/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
----------------------------------------------------------------------
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 e036751..dfc3f7d 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
@@ -46,7 +46,7 @@ import org.apache.sshd.server.session.ServerSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ShellCommand implements Command, SessionAware {
+public class ShellCommand implements Command, Runnable, SessionAware {
 
     public static final String SHELL_INIT_SCRIPT = "karaf.shell.init.script";
 
@@ -65,6 +65,7 @@ public class ShellCommand implements Command, SessionAware {
     private ExitCallback callback;
     private ServerSession session;
     private SessionFactory sessionFactory;
+    private Environment env;
 
     public ShellCommand(SessionFactory sessionFactory, String command) {
         this.sessionFactory = sessionFactory;
@@ -92,6 +93,11 @@ public class ShellCommand implements Command, SessionAware {
     }
 
     public void start(final Environment env) throws IOException {
+        this.env = env;
+        new Thread(this).start();
+    }
+
+    public void run() {
         int exitStatus = 0;
         try {
             final Session session = sessionFactory.create(in, new PrintStream(out), new PrintStream(err));
@@ -129,7 +135,7 @@ public class ShellCommand implements Command, SessionAware {
             }
         } catch (Exception e) {
             exitStatus = 1;
-            throw (IOException) new IOException("Unable to start shell").initCause(e);
+            LOGGER.error("Unable to start shell", e);
         } finally {
             StreamUtils.close(in, out, err);
             callback.onExit(exitStatus);