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));
|
return acquire(new ExecConnection(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ExecChannelConnection implements Connection<ExecChannel> {
|
class ExecChannelConnection implements Connection<ExecChannel> {
|
||||||
private final String command;
|
private final String command;
|
||||||
private SessionChannel session;
|
private SessionChannel session;
|
||||||
|
private Command output;
|
||||||
|
|
||||||
ExecChannelConnection(String command) {
|
ExecChannelConnection(String command) {
|
||||||
this.command = checkNotNull(command, "command");
|
this.command = checkNotNull(command, "command");
|
||||||
|
@ -515,35 +515,31 @@ public class SshjSshClient implements SshClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if (session != null)
|
Closeables.closeQuietly(output);
|
||||||
Closeables.closeQuietly(session);
|
Closeables.closeQuietly(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExecChannel create() throws Exception {
|
public ExecChannel create() throws Exception {
|
||||||
try {
|
session = SessionChannel.class.cast(acquire(execConnection()));
|
||||||
session = SessionChannel.class.cast(acquire(execConnection()));
|
output = session.exec(command);
|
||||||
Command output = session.exec(command);
|
return new ExecChannel(output.getOutputStream(), output.getInputStream(), output.getErrorStream(),
|
||||||
output.join(timeoutMillis, TimeUnit.SECONDS);
|
new Supplier<Integer>() {
|
||||||
return new ExecChannel(session.getOutputStream(), session.getInputStream(), session.getErrorStream(),
|
|
||||||
new Supplier<Integer>() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer get() {
|
public Integer get() {
|
||||||
return session.getExitStatus();
|
return output.getExitStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, new Closeable() {
|
}, new Closeable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue