8046500: GetIpAddrTable function failed on Pure Ipv6 environment
Reviewed-by: chegar
--- 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;
}