diff --git a/WHATSNEW b/WHATSNEW index 245bc460f..e300a3d2d 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -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 s. Note that some tasks diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java index 432ebb71f..bde08b8b2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Socket.java @@ -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; }