changeset 8452:3676f04e6553

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>
author bpb
date Tue, 15 Oct 2013 16:45:04 -0700
parents 78ffa90c77b2
children e33aea66caa3
files src/solaris/native/java/net/Inet4AddressImpl.c src/windows/native/java/net/Inet4AddressImpl.c src/windows/native/java/net/Inet6AddressImpl.c
diffstat 3 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/net/Inet4AddressImpl.c	Tue Oct 15 20:47:21 2013 +0100
+++ b/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/src/windows/native/java/net/Inet4AddressImpl.c	Tue Oct 15 20:47:21 2013 +0100
+++ b/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/src/windows/native/java/net/Inet6AddressImpl.c	Tue Oct 15 20:47:21 2013 +0100
+++ b/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);