You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/03/14 10:02:48 UTC

cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh SSHExec.java

bodewig     2005/03/14 01:02:48

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ssh
                        SSHExec.java
  Log:
  Explicitly disconnect the session, PR: 26757
  
  Revision  Changes    Path
  1.19      +6 -1      ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
  
  Index: SSHExec.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SSHExec.java	9 Mar 2005 00:20:41 -0000	1.18
  +++ SSHExec.java	14 Mar 2005 09:02:48 -0000	1.19
  @@ -137,9 +137,10 @@
           ByteArrayOutputStream out = new ByteArrayOutputStream();
           TeeOutputStream tee = new TeeOutputStream(out, System.out);
   
  +        Session session = null;
           try {
               // execute the command
  -            Session session = openSession();
  +            session = openSession();
               session.setTimeout((int) maxwait);
               final ChannelExec channel = (ChannelExec) session.openChannel("exec");
               channel.setCommand(command);
  @@ -219,6 +220,10 @@
               } else {
                   log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
               }
  +        } finally {
  +            if (session != null && session.isConnected()) {
  +                session.disconnect();
  +            }
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org