mirror of https://github.com/apache/jclouds.git
accidental close on finally block
This commit is contained in:
parent
dd7b16075e
commit
e39fc48901
|
@ -504,10 +504,10 @@ public class SshjSshClient implements SshClient {
|
|||
return acquire(new ExecConnection(command));
|
||||
}
|
||||
|
||||
|
||||
class ExecChannelConnection implements Connection<ExecChannel> {
|
||||
private final String command;
|
||||
private SessionChannel session;
|
||||
private Command output;
|
||||
|
||||
ExecChannelConnection(String command) {
|
||||
this.command = checkNotNull(command, "command");
|
||||
|
@ -515,22 +515,20 @@ public class SshjSshClient implements SshClient {
|
|||
|
||||
@Override
|
||||
public void clear() {
|
||||
if (session != null)
|
||||
Closeables.closeQuietly(output);
|
||||
Closeables.closeQuietly(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecChannel create() throws Exception {
|
||||
try {
|
||||
session = SessionChannel.class.cast(acquire(execConnection()));
|
||||
Command output = session.exec(command);
|
||||
output.join(timeoutMillis, TimeUnit.SECONDS);
|
||||
return new ExecChannel(session.getOutputStream(), session.getInputStream(), session.getErrorStream(),
|
||||
output = session.exec(command);
|
||||
return new ExecChannel(output.getOutputStream(), output.getInputStream(), output.getErrorStream(),
|
||||
new Supplier<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer get() {
|
||||
return session.getExitStatus();
|
||||
return output.getExitStatus();
|
||||
}
|
||||
|
||||
}, new Closeable() {
|
||||
|
@ -541,9 +539,7 @@ public class SshjSshClient implements SshClient {
|
|||
}
|
||||
|
||||
});
|
||||
} finally {
|
||||
clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue