You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2015/10/26 00:11:52 UTC
jclouds git commit: Close connection during ExecChannel
Repository: jclouds
Updated Branches:
refs/heads/master 502d96d22 -> 060b66a4f
Close connection during ExecChannel
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/060b66a4
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/060b66a4
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/060b66a4
Branch: refs/heads/master
Commit: 060b66a4f7f48aa9c2e79dafeb0540b896f39355
Parents: 502d96d
Author: Nikolay Sokolov <ch...@gmail.com>
Authored: Tue Jun 16 19:43:05 2015 +0300
Committer: Ignasi Barrera <na...@apache.org>
Committed: Sun Oct 25 23:02:33 2015 +0100
----------------------------------------------------------------------
compute/src/main/java/org/jclouds/ssh/SshClient.java | 4 +---
.../src/main/java/org/jclouds/sshj/SshjSshClient.java | 14 ++++++++++----
2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/060b66a4/compute/src/main/java/org/jclouds/ssh/SshClient.java
----------------------------------------------------------------------
diff --git a/compute/src/main/java/org/jclouds/ssh/SshClient.java b/compute/src/main/java/org/jclouds/ssh/SshClient.java
index f1cce77..f152aff 100644
--- a/compute/src/main/java/org/jclouds/ssh/SshClient.java
+++ b/compute/src/main/java/org/jclouds/ssh/SshClient.java
@@ -48,9 +48,7 @@ public interface SshClient {
ExecResponse exec(String command);
/**
- * Execute a process and allow the user to interact with it. Note that this will allow the
- * session to exist indefinitely, and its connection is not closed when {@link #disconnect()} is
- * called.
+ * Execute a process and allow the user to interact with it.
*
* @param command
* command line to invoke
http://git-wip-us.apache.org/repos/asf/jclouds/blob/060b66a4/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java
----------------------------------------------------------------------
diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java
index 2d2cb0d..b07b0e2 100644
--- a/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java
+++ b/drivers/sshj/src/main/java/org/jclouds/sshj/SshjSshClient.java
@@ -511,8 +511,8 @@ public class SshjSshClient implements SshClient {
class ExecChannelConnection implements Connection<ExecChannel> {
private final String command;
- private SessionChannel session;
private Command output;
+ private Connection<Session> connection;
ExecChannelConnection(String command) {
this.command = checkNotNull(command, "command");
@@ -521,13 +521,19 @@ public class SshjSshClient implements SshClient {
@Override
public void clear() {
Closeables2.closeQuietly(output);
- Closeables2.closeQuietly(session);
+ try {
+ if (connection != null) {
+ connection.clear();
+ }
+ } catch (Throwable e) {
+ Throwables.propagate(e);
+ }
}
@Override
public ExecChannel create() throws Exception {
- session = SessionChannel.class.cast(acquire(noPTYConnection()));
- output = session.exec(command);
+ connection = noPTYConnection();
+ output = SessionChannel.class.cast(acquire(connection)).exec(command);
return new ExecChannel(output.getOutputStream(), output.getInputStream(), output.getErrorStream(),
new Supplier<Integer>() {