You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2019/02/26 03:25:21 UTC

[ant] branch master updated (da9ca6e -> 9eb170b)

This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git.


    from da9ca6e  bz-63193 Introduce a readTimeout attribute for the "http" condition task
     new fe1ed77  Call InetAddress.isReachable instead of using reflection, now that we require Java 5 runtime for Ant
     add f04cc8b  Call InetAddress.isReachable instead of using reflection, now that we require Java 5 runtime for Ant
     new 9eb170b  Merge 1.9.x branch into master

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 WHATSNEW                                           |  5 ++++
 manual/Tasks/conditions.html                       |  6 ++--
 .../tools/ant/taskdefs/condition/IsReachable.java  | 35 +++++++---------------
 3 files changed, 17 insertions(+), 29 deletions(-)


[ant] 02/02: Merge 1.9.x branch into master

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git

commit 9eb170b4c2d8cab003ad1ba6d6a9fc7873a4e9ac
Merge: fe1ed77 f04cc8b
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Tue Feb 26 08:54:38 2019 +0530

    Merge 1.9.x branch into master

 manual/Tasks/conditions.html                                      | 1 +
 src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --cc manual/Tasks/conditions.html
index 97264f1,2af7b30..cc41d17
--- a/manual/Tasks/conditions.html
+++ b/manual/Tasks/conditions.html
@@@ -569,43 -632,58 +569,44 @@@ specifications, by attempting to set th
  <pre>
  &lt;parsersupports
    property="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"
 -  value="document.xsd"/&gt;
 -</pre>
 +  value="document.xsd"/&gt;</pre>
 +<p>Check for Xerces-specific definition of the location of the no namespace schema.</p>
  
 -Check for Xerces-specific definition of the location of the no namespace schema.
 +<h4 id="isreachable">isreachable</h4>
  
 -<h4><a name="isreachable">isreachable</a></h4>
 +<p>Uses Java 5+ networking APIs to probe for a (remote) system being reachable. Exactly what probe
 +mechanisms are used is an implementation feature of the JVM. They may include ICMP "ping" packets,
 +UDP or TCP connections to port 7 "echo service" or other means.</p>
 +<p>This condition turns unknown host exceptions into false conditions. This is because on a laptop,
 +DNS is one of the first services when the network goes; you are implicitly offline.</p>
 +<p>If a URL is supplied instead of a <var>host</var>, the hostname is extracted and used in the
 +test&mdash;all other parts of the URL are discarded.</p>
 +<p>The test may not work through firewalls, that is, something may be reachable using a protocol
 +such as HTTP, while the lower level ICMP packets get dropped on the floor. Similarly, a host may
 +detected as reachable with ICMP, but not reachable on other ports (i.e. port 80), because of
 +firewalls.</p>
 +<p><em>Since Apache Ant 1.7</em>.</p>
  
 -<p>Uses Java1.5+ networking APIs to probe for a (remote) system being
 -reachable. Exactly what probe mechanisms are used is an implementation
 -feature of the JVM. They may include ICMP "ping" packets, UDP or TCP connections
 -to port 7 "echo service" or other means.
 +<table class="attr">
+ 
 -</p>
 -<p>
 -This condition turns unknown host exceptions into false conditions. This is
 -because on a laptop, DNS is one of the first services when the network goes; you
 -are implicitly offline.
 -</p>
 -<p>
 - If a URL is supplied instead of a host, the hostname is extracted
 - and used in the test - all other parts of the URL are discarded.
 -</p>
 -<p>
 -The test may not work through firewalls, that is, something may be reachable
 -using a protocol such as HTTP, while the lower level ICMP packets get dropped
 -on the floor. Similarly, a host may detected as reachable with ICMP, but
 -not reachable on other ports (i.e. port 80), because of firewalls.
 -</p>
 -<p>
 -
 -This condition was added in Apache Ant 1.7.</p>
 -
 -<table border="1" cellpadding="2" cellspacing="0">
    <tr>
 -    <td valign="top"><b>Attribute</b></td>
 -    <td valign="top"><b>Description</b></td>
 -    <td align="center" valign="top"><b>Required</b></td>
 +    <th scope="col">Attribute</th>
 +    <th scope="col">Description</th>
 +    <th scope="col">Required</th>
    </tr>
    <tr>
 -    <td valign="top">host</td>
 -    <td valign="top">host to check for</td>
 -    <td valign="top" align="center">one of url or host</td>
 +    <td>host</td>
 +    <td>host to check for</td>
 +    <td rowspan="2">Exactly one of the two</td>
    </tr>
    <tr>
 -    <td valign="top">url</td>
 -    <td valign="top">URL containing hostname</td>
 -    <td valign="top" align="center">one of url or host</td>
 +    <td>url</td>
 +    <td class="left">URL containing hostname</td>
    </tr>
    <tr>
 -    <td valign="top">timeout</td>
 -    <td valign="top">timeout in seconds</td>
 -    <td valign="top" align="center">no, default is 30s</td>
 +    <td>timeout</td>
 +    <td>timeout in seconds</td>
 +    <td>No; default is <q>30</q></td>
    </tr>
  </table>
  


[ant] 01/02: Call InetAddress.isReachable instead of using reflection, now that we require Java 5 runtime for Ant

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jaikiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git

commit fe1ed7725d8ba7e62f9fb203659d22be2e54d3a0
Author: Jaikiran Pai <ja...@apache.org>
AuthorDate: Tue Feb 26 08:52:02 2019 +0530

    Call InetAddress.isReachable instead of using reflection, now that we require Java 5 runtime for Ant
---
 WHATSNEW                                           |  5 ++++
 manual/Tasks/conditions.html                       |  5 +---
 .../tools/ant/taskdefs/condition/IsReachable.java  | 32 +++++++---------------
 3 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/WHATSNEW b/WHATSNEW
index 0ec0b51..166dcd4 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -52,6 +52,11 @@ Fixed bugs:
    if failOnError was set to false.
    Bugzilla Report 63071
 
+ * The isreachable condition could in some cases return true even if the
+   actual address could potentially be unreachable. This is now fixed
+   and the resolved address is actually checked for reachability.
+
+
 Other changes:
 --------------
  * generatekey task now supports SubjectAlternativeName during key
diff --git a/manual/Tasks/conditions.html b/manual/Tasks/conditions.html
index d1d2e45..97264f1 100644
--- a/manual/Tasks/conditions.html
+++ b/manual/Tasks/conditions.html
@@ -576,10 +576,7 @@ specifications, by attempting to set the appropriate property/feature</p>
 
 <p>Uses Java 5+ networking APIs to probe for a (remote) system being reachable. Exactly what probe
 mechanisms are used is an implementation feature of the JVM. They may include ICMP "ping" packets,
-UDP or TCP connections to port 7 "echo service" or other means. On Java 1.4 and earlier, being able
-to resolve the hostname is considered success. This means that if DNS is not working or a
-URL/hostname is bad, the test will fail, but otherwise succeed even if the remote host is actually
-absent.</p>
+UDP or TCP connections to port 7 "echo service" or other means.</p>
 <p>This condition turns unknown host exceptions into false conditions. This is because on a laptop,
 DNS is one of the first services when the network goes; you are implicitly offline.</p>
 <p>If a URL is supplied instead of a <var>host</var>, the hostname is extracted and used in the
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
index e78d94b..e508a1c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
@@ -18,6 +18,7 @@
 
 package org.apache.tools.ant.taskdefs.condition;
 
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
@@ -85,7 +86,11 @@ public class IsReachable extends ProjectComponent implements Condition {
     public static final String ERROR_BAD_URL = "Bad URL ";
     /** Error message when no hostname in url. */
     public static final String ERROR_NO_HOST_IN_URL = "No hostname in URL ";
-    /** The method name to look for in InetAddress */
+    /**
+     * The method name to look for in InetAddress
+     * @deprecated Since 1.10.6
+     */
+    @Deprecated
     public static final String METHOD_NAME = "isReachable";
 
     private String host;
@@ -174,28 +179,11 @@ public class IsReachable extends ProjectComponent implements Condition {
         log("Host address = " + address.getHostAddress(),
                 Project.MSG_VERBOSE);
         boolean reachable;
-        //Java1.5: reachable = address.isReachable(timeout * 1000);
         try {
-            Method reachableMethod =
-                InetAddress.class.getMethod(METHOD_NAME, Integer.class);
-            try {
-                reachable = (Boolean) reachableMethod.invoke(address,
-                        timeout * SECOND);
-            } catch (final IllegalAccessException e) {
-                //utterly implausible, but catered for anyway
-                throw new BuildException("When calling " + reachableMethod);
-            } catch (final InvocationTargetException e) {
-                //assume this is an IOException about un readability
-                final Throwable nested = e.getTargetException();
-                log(ERROR_ON_NETWORK + target + ": " + nested.toString());
-                //any kind of fault: not reachable.
-                reachable = false;
-            }
-        } catch (final NoSuchMethodException e) {
-            //java1.4
-            log("Not found: InetAddress." + METHOD_NAME, Project.MSG_VERBOSE);
-            log(MSG_NO_REACHABLE_TEST);
-            reachable = true;
+            reachable = address.isReachable(timeout * SECOND);
+        } catch (final IOException ioe) {
+            reachable = false;
+            log(ERROR_ON_NETWORK + target + ": " + ioe.toString());
         }
 
         log("host is" + (reachable ? "" : " not") + " reachable", Project.MSG_VERBOSE);