Browse Source

Explicitly disconnect the session, PR: 26757

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277914 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
e7dd85e3dc
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

+ 6
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java View File

@@ -137,9 +137,10 @@ public class SSHExec extends SSHBase {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
TeeOutputStream tee = new TeeOutputStream(out, System.out); TeeOutputStream tee = new TeeOutputStream(out, System.out);


Session session = null;
try { try {
// execute the command // execute the command
Session session = openSession();
session = openSession();
session.setTimeout((int) maxwait); session.setTimeout((int) maxwait);
final ChannelExec channel = (ChannelExec) session.openChannel("exec"); final ChannelExec channel = (ChannelExec) session.openChannel("exec");
channel.setCommand(command); channel.setCommand(command);
@@ -219,6 +220,10 @@ public class SSHExec extends SSHBase {
} else { } else {
log("Caught exception: " + e.getMessage(), Project.MSG_ERR); log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
} }
} finally {
if (session != null && session.isConnected()) {
session.disconnect();
}
} }
} }




Loading…
Cancel
Save