-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b19
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8018881 | 7u45 | Neil Richards | P4 | Closed | Fixed | b01 |
JDK-2226986 | 7u40 | Sean Coffey | P4 | Closed | Fixed | b01 |
On some Linuxes, when bound to the loopback interface, sendto may fail with an EINVAL errno (see CR 6947677), and on others (AIX, iSeries) it will throw an EHOSTUNREACH errno. In such situation, EHOSTUNREACH should be treated the same as EINVAL, not
throw an exception but return false.
Below is the simple testcase that can demonstrate this on specific platforms:
public class IsReachableTest {
public static void main(String[] args) throws Exception{
InetAddress testHost1 = InetAddress.getByName("openjdk.java.net");
NetworkInterface loopbackNi = null;
Enumeration<NetworkInterface> list =
NetworkInterface.getNetworkInterfaces();
boolean loopbackFound = false;
while (list.hasMoreElements() && !loopbackFound){
loopbackNi = list.nextElement();
if (loopbackNi.isLoopback() && loopbackNi.isUp()) {
loopbackFound = true;
}
}
if (!loopbackFound)
return;
if (testHost1.isReachable(loopbackNi, 64, 1000))
System.out.println(String.format("Fail: external host '%s' is reachable via loopback '%s'!", testHost1, loopbackNi));
}
}
see the mail thread on the net-dev mailing list for further details:
http://mail.openjdk.java.net/pipermail/net-dev/2011-December/003839.html
throw an exception but return false.
Below is the simple testcase that can demonstrate this on specific platforms:
public class IsReachableTest {
public static void main(String[] args) throws Exception{
InetAddress testHost1 = InetAddress.getByName("openjdk.java.net");
NetworkInterface loopbackNi = null;
Enumeration<NetworkInterface> list =
NetworkInterface.getNetworkInterfaces();
boolean loopbackFound = false;
while (list.hasMoreElements() && !loopbackFound){
loopbackNi = list.nextElement();
if (loopbackNi.isLoopback() && loopbackNi.isUp()) {
loopbackFound = true;
}
}
if (!loopbackFound)
return;
if (testHost1.isReachable(loopbackNi, 64, 1000))
System.out.println(String.format("Fail: external host '%s' is reachable via loopback '%s'!", testHost1, loopbackNi));
}
}
see the mail thread on the net-dev mailing list for further details:
http://mail.openjdk.java.net/pipermail/net-dev/2011-December/003839.html
- backported by
-
JDK-2226986 InetAddress.isReachable() should return false if sendto fails with EHOSTUNREACH
-
- Closed
-
-
JDK-8018881 InetAddress.isReachable() should return false if sendto fails with EHOSTUNREACH
-
- Closed
-