src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
changeset 52670 eb6864cdcd61
parent 51153 78f16a9f7563
child 53381 e1da82072c79
--- a/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Fri Nov 23 16:36:07 2018 +0900
+++ b/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Fri Nov 23 13:16:45 2018 +0530
@@ -684,19 +684,21 @@
                 packetAddress = NULL;
             }
         }
-        if (packetAddress == NULL) {
-            packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
-            /* stuff the new Inetaddress in the packet */
-            (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
-        } else {
-            /* only get the new port number */
-            port = NET_GetPortFromSockaddr(&rmtaddr);
+        if (!(*env)->ExceptionCheck(env)){
+            if (packetAddress == NULL ) {
+                packetAddress = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
+                /* stuff the new InetAddress in the packet */
+                (*env)->SetObjectField(env, packet, dp_addressID, packetAddress);
+            } else {
+                /* only get the new port number */
+                port = NET_GetPortFromSockaddr(&rmtaddr);
+            }
+            /* and fill in the data, remote address/port and such */
+            (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
+                                    (jbyte *)fullPacket);
+            (*env)->SetIntField(env, packet, dp_portID, port);
+            (*env)->SetIntField(env, packet, dp_lengthID, n);
         }
-        /* and fill in the data, remote address/port and such */
-        (*env)->SetByteArrayRegion(env, packetBuffer, packetBufferOffset, n,
-                                   (jbyte *)fullPacket);
-        (*env)->SetIntField(env, packet, dp_portID, port);
-        (*env)->SetIntField(env, packet, dp_lengthID, n);
     }
 
     if (mallocedPacket) {