From e8093d981337aff4678bf0de9c713e66546add1a Mon Sep 17 00:00:00 2001 From: bpb Date: Tue, 15 Oct 2013 16:45:04 -0700 Subject: [PATCH] 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 --- src/solaris/native/java/net/Inet4AddressImpl.c | 3 +-- src/windows/native/java/net/Inet4AddressImpl.c | 4 ++++ src/windows/native/java/net/Inet6AddressImpl.c | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/solaris/native/java/net/Inet4AddressImpl.c b/src/solaris/native/java/net/Inet4AddressImpl.c index 9a4d32ebf..44f3b7aa4 100644 --- a/src/solaris/native/java/net/Inet4AddressImpl.c +++ b/src/solaris/native/java/net/Inet4AddressImpl.c @@ -178,8 +178,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, if (error) { /* report error */ - JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", - (char *)hostname); + ThrowUnknownHostExceptionWithGaiError(env, hostname, error); JNU_ReleaseStringPlatformChars(env, host, hostname); return NULL; } else { diff --git a/src/windows/native/java/net/Inet4AddressImpl.c b/src/windows/native/java/net/Inet4AddressImpl.c index d7cf8e5a3..97aab6f9c 100644 --- a/src/windows/native/java/net/Inet4AddressImpl.c +++ b/src/windows/native/java/net/Inet4AddressImpl.c @@ -241,6 +241,10 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, addrp++; i++; } + } else if (WSAGetLastError() == WSATRY_AGAIN) { + NET_ThrowByNameWithLastError(env, + JNU_JAVANETPKG "UnknownHostException", + hostname); } else { JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", hostname); } diff --git a/src/windows/native/java/net/Inet6AddressImpl.c b/src/windows/native/java/net/Inet6AddressImpl.c index c124f91f4..0e6fc308a 100644 --- a/src/windows/native/java/net/Inet6AddressImpl.c +++ b/src/windows/native/java/net/Inet6AddressImpl.c @@ -131,7 +131,13 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, 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); -- GitLab