8143397: It looks like InetAddress.isReachable(timeout) works incorrectly

Rob McKenna rob.mckenna at oracle.com
Tue Dec 1 14:59:31 UTC 2015


It appears that there is an undocumented minimum timeout in the 
IcmpSendEcho* functions. If the timeout parameter is set to a number 
below this minimum timeout it is effectively ignored. Thus if you wanted 
to ensure that you could ping a particular host within a certain timeout 
less than the undocumented minimum, you could potentially receive a 
false positive. (i.e. if you set the timeout to 20ms but the ping takes 
30ms, IcmpSendEcho will still succeed)

The following fix checks the icmp reply packet and compares the round 
trip time to the requested timeout parameter before deciding whether the 
call was successful or not:

http://cr.openjdk.java.net/~robm/8143397/webrev.01/

	-Rob


More information about the net-dev mailing list