8046500: GetIpAddrTable function failed on Pure Ipv6 environment
authorvtewari
Thu, 22 Nov 2018 13:25:44 +0530
changeset 52651 526b2490c616
parent 52650 c16b6cc93272
child 52652 d9d3b14b2cfa
8046500: GetIpAddrTable function failed on Pure Ipv6 environment Reviewed-by: chegar
src/java.base/windows/native/libnet/NetworkInterface.c
src/java.base/windows/native/libnet/NetworkInterface_winXP.c
--- a/src/java.base/windows/native/libnet/NetworkInterface.c	Wed Nov 21 22:34:01 2018 -0800
+++ b/src/java.base/windows/native/libnet/NetworkInterface.c	Thu Nov 22 13:25:44 2018 +0530
@@ -202,8 +202,9 @@
 
         JNU_ThrowByName(env, "java/lang/Error",
                 "IP Helper Library GetIfTable function failed");
-
-        return -1;
+        // this different error code is to handle the case when we call
+        // GetIpAddrTable in pure IPv6 environment
+        return -2;
     }
 
     /*
@@ -400,7 +401,9 @@
         }
         JNU_ThrowByName(env, "java/lang/Error",
                 "IP Helper Library GetIpAddrTable function failed");
-        return -1;
+        // this different error code is to handle the case when we call
+        // GetIpAddrTable in pure IPv6 environment
+        return -2;
     }
 
     /*
@@ -557,7 +560,7 @@
      */
     if (netaddrCount < 0) {
         netaddrCount = enumAddresses_win(env, ifs, &netaddrP);
-        if (netaddrCount == -1) {
+        if (netaddrCount < 0) {
             return NULL;
         }
     }
--- a/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Wed Nov 21 22:34:01 2018 -0800
+++ b/src/java.base/windows/native/libnet/NetworkInterface_winXP.c	Thu Nov 22 13:25:44 2018 +0530
@@ -253,6 +253,10 @@
     ret = enumInterfaces(env, netifPP);
     if (ret == -1) {
         return -1;
+    } else if( ret == -2){
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+        }
     } else {
         count = ret;
     }
@@ -272,10 +276,16 @@
         ret = enumAddresses_win(env, curr, &netaddrP);
         if (ret == -1) {
             return -1;
+        } else if (ret == -2) {
+            if ((*env)->ExceptionCheck(env)) {
+                (*env)->ExceptionClear(env);
+            }
+            break;
+        } else{
+            curr->addrs = netaddrP;
+            curr->naddrs += ret;
+            curr = curr->next;
         }
-        curr->addrs = netaddrP;
-        curr->naddrs += ret;
-        curr = curr->next;
     }
 
     ret = getAdapters (env, &adapters);
@@ -558,6 +568,12 @@
         if (netaddrCount == -1) {
             return NULL;
         }
+        if (netaddrCount == -2) {
+            // Clear the exception and continue.
+            if ((*env)->ExceptionCheck(env)) {
+                (*env)->ExceptionClear(env);
+            }
+        }
         netaddrP = netaddrPToFree;
     }