prototype0815
prototype0815

Reputation: 620

Why does Java InetAddress.isReachable() not work on JRE 1.8.x like on JRE 1.7.x

I've written a programm a year ago and today I saw that this programm give me some curious output. One kind to detect PC's or notebooks in our network I'm using the InetAddress class. My programm works how it should, until Java 1.8.x runs on the executing machine, than the InetAddress.isReachable() gives me a "TRUE" also if there is no machine on that IP address.

private String ipAddress = "192.168.1.200";
inetAddr = InetAddress.getByName(ipAddress);
inetIsReachable = inetAddr.isReachable(8000);
debug += "   INET is reachable: " + inetIsReachable;
System.out.println(debug);

That is really strange, and I don't know how to detect this error.

Kind regards proto

°°°°°EDIT

I tried this code... running on Java 1.7

  inetAddr = InetAddress.getByName(ipAddress);
  inetIsReachable = inetAddr.isReachable(8000);
// FALSE
  byte[] a = new byte[]{(byte) 192,(byte) 168,1,(byte) 200};
  inetAddr = InetAddress.getByAddress("192.168.1.200", a);
  inetIsReachable = inetAddr.isReachable(8000);
// also FALSE

But a ping on commandline reaches the machine!

°°°°°EDIT-2

Java 1.8

192.168.1.200 - InetAddress true - cmd ping true - there is a machine

192.168.1.202 - InetAddress true - cmd ping false - there is no machine

Java 1.7

192.168.1.200 - InetAddress false - cmd ping true - there is a machine

192.168.1.202 - InetAddress false - cmd ping false- there is no machine

Upvotes: 3

Views: 1529

Answers (1)

assylias
assylias

Reputation: 328835

This looks like bug #JDK-8159410, apparently introduced after 8u73.

Upvotes: 1

Related Questions