8010371: getaddrinfo can fail with EAI_SYSTEM/EAGAIN, causes UnknownHostException to be thrown
Summary: Modify UHE exception message for EAI_AGAIN failures.
Reviewed-by: alanb, chegar, michaelm, dsamersoff
Contributed-by: Brian Burkhalter <brian.burkhalter@oracle.com>
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Tue Oct 15 20:47:21 2013 +0100
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Tue Oct 15 16:45:04 2013 -0700
@@ -178,8 +178,7 @@
if (error) {
/* report error */
- JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
- (char *)hostname);
+ ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
--- a/jdk/src/windows/native/java/net/Inet4AddressImpl.c Tue Oct 15 20:47:21 2013 +0100
+++ b/jdk/src/windows/native/java/net/Inet4AddressImpl.c Tue Oct 15 16:45:04 2013 -0700
@@ -241,6 +241,10 @@
addrp++;
i++;
}
+ } else if (WSAGetLastError() == WSATRY_AGAIN) {
+ NET_ThrowByNameWithLastError(env,
+ JNU_JAVANETPKG "UnknownHostException",
+ hostname);
} else {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", hostname);
}
--- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c Tue Oct 15 20:47:21 2013 +0100
+++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c Tue Oct 15 16:45:04 2013 -0700
@@ -131,7 +131,13 @@
error = getaddrinfo(hostname, NULL, &hints, &res);
- if (error) {
+ if (WSAGetLastError() == WSATRY_AGAIN) {
+ NET_ThrowByNameWithLastError(env,
+ JNU_JAVANETPKG "UnknownHostException",
+ hostname);
+ JNU_ReleaseStringPlatformChars(env, host, hostname);
+ return NULL;
+ } else if (error) {
/* report error */
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);