You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
2.1 KiB
49 lines
2.1 KiB
3 years ago
|
--- apache-ant-1.9.16.orig/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
|
||
|
+++ apache-ant-1.9.16/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
|
||
|
@@ -131,6 +131,8 @@
|
||
|
return string == null || string.length() == 0;
|
||
|
}
|
||
|
|
||
|
+ private static Class[] parameterTypes = {Integer.TYPE};
|
||
|
+
|
||
|
/**
|
||
|
* Evaluate the condition.
|
||
|
*
|
||
|
@@ -173,11 +175,32 @@
|
||
|
log("Host address = " + address.getHostAddress(),
|
||
|
Project.MSG_VERBOSE);
|
||
|
boolean reachable;
|
||
|
+ //Java1.5: reachable = address.isReachable(timeout * 1000);
|
||
|
+ Method reachableMethod = null;
|
||
|
try {
|
||
|
- reachable = address.isReachable(timeout * SECOND);
|
||
|
- } catch (final IOException ioe) {
|
||
|
- reachable = false;
|
||
|
- log(ERROR_ON_NETWORK + target + ": " + ioe.toString());
|
||
|
+ reachableMethod = InetAddress.class.getMethod(METHOD_NAME,
|
||
|
+ parameterTypes);
|
||
|
+ final Object[] params = new Object[1];
|
||
|
+ params[0] = new Integer(timeout * SECOND);
|
||
|
+ try {
|
||
|
+ reachable = ((Boolean) reachableMethod.invoke(address, params))
|
||
|
+ .booleanValue();
|
||
|
+ } 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;
|
||
|
+
|
||
|
}
|
||
|
|
||
|
log("host is" + (reachable ? "" : " not") + " reachable", Project.MSG_VERBOSE);
|