FULL PRODUCT VERSION :
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux alainodea-xps-l521x 3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
A DESCRIPTION OF THE PROBLEM :
I think I have identified a regression in network error handling from Java 7 to Java 8.
In Java 7, attempts to resolve a host unknown to the DNS server cause an UnknownHostException stating "Name or service not known".
In Java 8, attempts to resolve a host unknown to the DNS server cause an UnknownHostException stating "unknown error".
Possible root cause:
It appears that Java 7 had initialization that allowed the gai_strerror_ptr function pointer to be correctly initialized:
http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/9b8c96f96a0f/src/solaris/native/java/net/net_util_md.c#l398
However, I cannot find equivalent initialization in JDK 8:
http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/solaris/native/java/net/net_util_md.c
REGRESSION. Last worked in version 7u80
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a file called InetAddressGetAllByName.java with the content from the source code I have listed on this case
2. Compile InetAddressGetAllByName.java:
javac InetAddressGetAllByName.java
3. Run InetAddressGetAllByName
java InetAddressGetAllByName
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The following is the
Exception in thread "main" java.net.UnknownHostException: doesnotexist.example.com: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)
at java.net.InetAddress.getAllByName0(InetAddress.java:1248)
at java.net.InetAddress.getAllByName(InetAddress.java:1164)
at java.net.InetAddress.getAllByName(InetAddress.java:1098)
at InetAddressGetAllByName.main(InetAddressGetAllByName.java:7)
ACTUAL -
Exception in thread "main" java.net.UnknownHostException: doesnotexist.example.com: unknown error
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at InetAddressGetAllByName.main(InetAddressGetAllByName.java:7)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
public class InetAddressGetAllByName {
public static void main(String[] args) throws UnknownHostException {
System.out.println(Arrays.toString(InetAddress.getAllByName("doesnotexist.example.com")));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use filtered system call tracing to determine actual causes when this happens.