bodewig 2004/06/23 05:26:35
Modified: . Tag: ANT_16_BRANCH TODO WHATSNEW
src/main/org/apache/tools/ant/taskdefs/optional/net Tag:
ANT_16_BRANCH TelnetTask.java
Log:
merge
Revision Changes Path
No revision
No revision
1.3.2.20 +0 -3 ant/Attic/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/ant/Attic/TODO,v
retrieving revision 1.3.2.19
retrieving revision 1.3.2.20
diff -u -r1.3.2.19 -r1.3.2.20
--- TODO 22 Jun 2004 21:30:55 -0000 1.3.2.19
+++ TODO 23 Jun 2004 12:26:34 -0000 1.3.2.20
@@ -18,9 +18,6 @@
* <junitreport> and JDK 1.5 [Stefan hopes that Stephane solves it for
him, otherwise he'll do it himself]
-* telnet doesn't disconnect properly (PR 25935) [Stefan unless Peter
- is faster].
-
* AntClassLoader parent loader [Start thread, Peter]
* delete - do not follow symlinks [Peter, may be dropped for 1.6.2]
1.503.2.111 +2 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.503.2.110
retrieving revision 1.503.2.111
diff -u -r1.503.2.110 -r1.503.2.111
--- WHATSNEW 22 Jun 2004 21:30:55 -0000 1.503.2.110
+++ WHATSNEW 23 Jun 2004 12:26:34 -0000 1.503.2.111
@@ -116,6 +116,8 @@
* <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.
+
Other changes:
--------------
* doc fix concerning the dependencies of the ftp task
No revision
No revision
1.20.2.6 +30 -23
ant/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
Index: TelnetTask.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java,v
retrieving revision 1.20.2.5
retrieving revision 1.20.2.6
diff -u -r1.20.2.5 -r1.20.2.6
--- TelnetTask.java 9 Mar 2004 17:01:51 -0000 1.20.2.5
+++ TelnetTask.java 23 Jun 2004 12:26:35 -0000 1.20.2.6
@@ -56,11 +56,6 @@
private int port = 23;
/**
- * The Object which handles the telnet session.
- */
- private AntTelnetClient telnet = null;
-
- /**
* The list of read/write commands for this session
*/
private Vector telnetTasks = new Vector();
@@ -97,24 +92,36 @@
}
/** Create the telnet client object */
- telnet = new AntTelnetClient();
+ AntTelnetClient telnet = null;
try {
- telnet.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 = telnetTasks.elements();
- while (tasksToRun != null && tasksToRun.hasMoreElements()) {
- TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement();
- if (task instanceof TelnetRead && defaultTimeout != null) {
- ((TelnetRead) task).setDefaultTimeout(defaultTimeout);
+ telnet = new AntTelnetClient();
+ try {
+ telnet.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(telnet);
+ }
+ /** Process each sub command */
+ Enumeration tasksToRun = telnetTasks.elements();
+ while (tasksToRun != null && tasksToRun.hasMoreElements()) {
+ TelnetSubTask task = (TelnetSubTask) tasksToRun.nextElement();
+ if (task instanceof TelnetRead && defaultTimeout != null) {
+ ((TelnetRead) task).setDefaultTimeout(defaultTimeout);
+ }
+ task.execute(telnet);
+ }
+ } finally {
+ if (telnet != null) {
+ try {
+ telnet.disconnect();
+ } catch (IOException e) {
+ throw new BuildException("Error disconnecting from "
+ + server);
+ }
}
- task.execute(telnet);
}
}
@@ -122,7 +129,7 @@
* Process a 'typical' login. If it differs, use the read
* and write tasks explicitely
*/
- private void login() {
+ private void login(AntTelnetClient telnet) {
if (addCarriageReturn) {
telnet.sendString("\n", true);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]