< prev index next >

src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c

Print this page
rev 14890 : 8158023: SocketExceptions contain too little information sometimes

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -1711,12 +1711,12 @@
             struct in_addr in;
 
             in.s_addr = htonl(getInetAddress_addr(env, value));
             if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                                (const char*)&in, sizeof(in)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                 "Error setting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
             }
             return;
         }
     }
 

@@ -1739,34 +1739,34 @@
                 ni_indexID = (*env)->GetFieldID(env, c, "index", "I");
                 CHECK_NULL(ni_indexID);
             }
             index = (*env)->GetIntField(env, value, ni_indexID);
 
-            if ( isAdapterIpv6Enabled(env, index) != 0 ) {
+            if (isAdapterIpv6Enabled(env, index) != 0) {
                 if (setsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                                (const char*)&index, sizeof(index)) < 0) {
                     if (errno == EINVAL && index > 0) {
                         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                             "IPV6_MULTICAST_IF failed (interface has IPv4 "
                             "address only?)");
                     } else {
-                        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                   "Error setting socket option");
+                        JNU_ThrowByNameWithMessageAndLastError
+                            (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
                     }
                     return;
                 }
             }
             /* If there are any IPv4 addresses on this interface then
              * repeat the operation on the IPv4 fd */
 
-            if (getInet4AddrFromIf (env, value, &in) < 0) {
+            if (getInet4AddrFromIf(env, value, &in) < 0) {
                 return;
             }
             if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                                (const char*)&in, sizeof(in)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                 "Error setting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
             }
             return;
         } else {
             struct in_addr in;
 

@@ -1779,12 +1779,12 @@
                 return;
             }
 
             if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                                (const char*)&in, sizeof(in)) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                               "Error setting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
             }
             return;
         }
     }
 }

@@ -1930,12 +1930,12 @@
         struct in_addr in;
         struct in_addr *inP = &in;
         int len = sizeof(struct in_addr);
         if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
                            (char *)inP, &len) < 0) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                             "Error getting socket option");
+            JNU_ThrowByNameWithMessageAndLastError
+                (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
             return NULL;
         }
 
         /*
          * Construct and populate an Inet4Address

@@ -2054,12 +2054,12 @@
         jobject ni;
 
         {
             if (getsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
                                (char*)&index, &len) < 0) {
-                NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                               "Error getting socket option");
+                JNU_ThrowByNameWithMessageAndLastError
+                    (env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
                 return NULL;
             }
         }
 
         if (ni_class == NULL) {

@@ -2286,12 +2286,12 @@
                         "Socket closed");
         return NULL;
     }
 
     if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
-        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                       "Error getting socket name");
+        JNU_ThrowByNameWithMessageAndLastError
+            (env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
         return NULL;
     }
     iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
 
     return iaObj;
< prev index next >