Browse Source

close the socket created by the socket condition

I have tested the issue. With the new code, within approximatively 100 milliseconds,
the socket is gone while ant keeps running.
PR: 23040
Submitted by: John C. Kendall (jkendall at technologist dot com)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275217 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 22 years ago
parent
commit
2d0bb7d9c0
2 changed files with 15 additions and 1 deletions
  1. +3
    -0
      WHATSNEW
  2. +12
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Socket.java

+ 3
- 0
WHATSNEW View File

@@ -236,6 +236,9 @@ Fixed bugs:
* Project.toBoolean(String) now handles null as argument and does not throw a
NullPointerException any more.

* The socket condition will now close the socket created to test.
Bugzilla Report 23040.

Other changes:
--------------
* All tasks can be used outside of <target>s. Note that some tasks


+ 12
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Socket.java View File

@@ -103,11 +103,22 @@ public class Socket extends ProjectComponent implements Condition {
}
log("Checking for listener at " + server + ":" + port,
Project.MSG_VERBOSE);
java.net.Socket s = null;
try {
new java.net.Socket(server, port);
s = new java.net.Socket(server, port);
} catch (IOException e) {
return false;
}
finally {
if (s != null){
try {
s.close();
}
catch (IOException ioe){
// Intentionally left blank
}
}
}
return true;
}



Loading…
Cancel
Save