Browse Source

PR 25935 applies to <rexec> as well

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276613 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
8fac17d331
2 changed files with 33 additions and 26 deletions
  1. +1
    -1
      WHATSNEW
  2. +32
    -25
      src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java

+ 1
- 1
WHATSNEW View File

@@ -151,7 +151,7 @@ Fixed bugs:
* <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:
--------------


+ 32
- 25
src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java View File

@@ -61,11 +61,6 @@ public class RExecTask extends Task {
*/
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
*/
@@ -322,34 +317,46 @@ public class RExecTask extends Task {
}

/** 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);
}


Loading…
Cancel
Save