ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/net RExecTask.java
Date Wed, 23 Jun 2004 12:32:04 GMT
bodewig     2004/06/23 05:32:04

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/taskdefs/optional/net Tag:
                        ANT_16_BRANCH RExecTask.java
  Log:
  merge
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.112 +1 -1      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.111
  retrieving revision 1.503.2.112
  diff -u -r1.503.2.111 -r1.503.2.112
  --- WHATSNEW	23 Jun 2004 12:26:34 -0000	1.503.2.111
  +++ WHATSNEW	23 Jun 2004 12:32:03 -0000	1.503.2.112
  @@ -116,7 +116,7 @@
   * <scp> now has (local|remote)tofile attributes to rename files on the
     fly.  Bugzilla Report 26758.
   
  -* <telnet> didn't close the session.  Bugzilla Report 25935.
  +* <telnet> and <rexec> didn't close the session.  Bugzilla Report 25935.
   
   Other changes:
   --------------
  
  
  
  No                   revision
  No                   revision
  1.4.2.4   +32 -25    ant/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
  
  Index: RExecTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java,v
  retrieving revision 1.4.2.3
  retrieving revision 1.4.2.4
  diff -u -r1.4.2.3 -r1.4.2.4
  --- RExecTask.java	9 Feb 2004 22:12:35 -0000	1.4.2.3
  +++ RExecTask.java	23 Jun 2004 12:32:03 -0000	1.4.2.4
  @@ -62,11 +62,6 @@
       private int port = RExecClient.DEFAULT_PORT;
   
       /**
  -     *  The Object which handles the rexec session.
  -     */
  -    private AntRExecClient rexec = null;
  -
  -    /**
        *  The list of read/write commands for this session
        */
       private Vector rexecTasks = new Vector();
  @@ -322,34 +317,46 @@
           }
   
           /**  Create the telnet client object */
  -        rexec = new AntRExecClient();
  +        AntRExecClient rexec = null;
           try {
  -            rexec.connect(server, port);
  -        } catch (IOException e) {
  -            throw new BuildException("Can't connect to " + server);
  -        }
  -        /**  Login if userid and password were specified */
  -        if (userid != null && password != null) {
  -            login();
  -        }
  -        /**  Process each sub command */
  -        Enumeration tasksToRun = rexecTasks.elements();
  -        while (tasksToRun != null && tasksToRun.hasMoreElements()) {
  -            RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
  -            if (task instanceof RExecRead && defaultTimeout != null) {
  -                ((RExecRead) task).setDefaultTimeout(defaultTimeout);
  +            rexec = new AntRExecClient();
  +            try {
  +                rexec.connect(server, port);
  +            } catch (IOException e) {
  +                throw new BuildException("Can't connect to " + server);
  +            }
  +            /**  Login if userid and password were specified */
  +            if (userid != null && password != null) {
  +                login(rexec);
  +            }
  +            /**  Process each sub command */
  +            Enumeration tasksToRun = rexecTasks.elements();
  +            while (tasksToRun != null && tasksToRun.hasMoreElements()) {
  +                RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
  +                if (task instanceof RExecRead && defaultTimeout != null) {
  +                    ((RExecRead) task).setDefaultTimeout(defaultTimeout);
  +                }
  +                task.execute(rexec);
               }
  -            task.execute(rexec);
  -        }
   
  -        /** Keep reading input stream until end of it or time-out */
  -        rexec.waitForEOF(defaultTimeout);
  +            /** Keep reading input stream until end of it or time-out */
  +            rexec.waitForEOF(defaultTimeout);
  +       } finally {
  +           if (rexec != null) {
  +               try {
  +                   rexec.disconnect();
  +               } catch (IOException e) {
  +                   throw new BuildException("Error disconnecting from " 
  +                                            + server);
  +               }
  +           }
  +       }
       }
       /**
        *  Process a 'typical' login.  If it differs, use the read
        *  and write tasks explicitely
        */
  -    private void login() {
  +    private void login(AntRExecClient rexec) {
           if (addCarriageReturn) {
               rexec.sendString("\n", true);
           }
  
  
  

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


Mime
View raw message