You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2013/07/17 22:12:57 UTC
git commit: [SSHD-225] InvertedShellWrapper does not shutdown its
executor, preventing graceful JVM exit
Updated Branches:
refs/heads/master 5e69ae74a -> eeeec6041
[SSHD-225] InvertedShellWrapper does not shutdown its executor, preventing graceful JVM exit
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/eeeec604
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/eeeec604
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/eeeec604
Branch: refs/heads/master
Commit: eeeec604180e317c4e0c03d0128c92f5d86b0f0f
Parents: 5e69ae7
Author: Guillaume Nodet <gn...@apache.org>
Authored: Wed Jul 17 22:12:45 2013 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Wed Jul 17 22:12:45 2013 +0200
----------------------------------------------------------------------
.../sshd/server/shell/InvertedShellWrapper.java | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/eeeec604/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
index 65980ac..08d2642 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.mina.util.NamePreservingRunnable;
@@ -33,7 +34,7 @@ import org.apache.sshd.server.session.ServerSession;
/**
* A shell implementation that wraps an instance of {@link InvertedShell}
- * as a {@link ShellFactory.Shell}. This is useful when using external
+ * as a {@link Command}. This is useful when using external
* processes.
* When starting the shell, this wrapper will also create a thread used
* to pump the streams and also to check if the shell is alive.
@@ -55,23 +56,29 @@ public class InvertedShellWrapper implements Command, SessionAware {
private InputStream shellOut;
private InputStream shellErr;
private ExitCallback callback;
+ private boolean shutdownExecutor;
public InvertedShellWrapper(InvertedShell shell) {
- this(shell, Executors.newSingleThreadExecutor(), DEFAULT_BUFFER_SIZE);
+ this(shell, Executors.newSingleThreadExecutor(), true, DEFAULT_BUFFER_SIZE);
}
public InvertedShellWrapper(InvertedShell shell, Executor executor) {
- this(shell, executor, DEFAULT_BUFFER_SIZE);
+ this(shell, executor, false, DEFAULT_BUFFER_SIZE);
}
public InvertedShellWrapper(InvertedShell shell, int bufferSize) {
- this(shell, Executors.newSingleThreadExecutor(), bufferSize);
+ this(shell, Executors.newSingleThreadExecutor(), true, bufferSize);
}
public InvertedShellWrapper(InvertedShell shell, Executor executor, int bufferSize) {
+ this(shell, executor, false, bufferSize);
+ }
+
+ public InvertedShellWrapper(InvertedShell shell, Executor executor, boolean shutdownExecutor, int bufferSize) {
this.shell = shell;
this.executor = executor;
this.bufferSize = bufferSize;
+ this.shutdownExecutor = shutdownExecutor;
}
public void setInputStream(InputStream in) {
@@ -111,6 +118,9 @@ public class InvertedShellWrapper implements Command, SessionAware {
public void destroy() {
shell.destroy();
+ if (shutdownExecutor && executor instanceof ExecutorService) {
+ ((ExecutorService) executor).shutdown();
+ }
}
protected void pumpStreams() {