mirror of
https://github.com/apache/jclouds.git
synced 2025-02-16 06:56:45 +00:00
Close connection during ExecChannel
This commit is contained in:
parent
bdbed1ced5
commit
c6f47ca904
@ -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
|
||||
|
@ -500,8 +500,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");
|
||||
@ -510,13 +510,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>() {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user