Have connection reset by peer message be same as PlainSocketImpl niosocketimpl-branch
authoralanb
Fri, 01 Mar 2019 17:40:16 +0000
branchniosocketimpl-branch
changeset 57237 a0ad3ffd7b60
parent 57236 510cfa118408
child 57238 b145b1b04106
Have connection reset by peer message be same as PlainSocketImpl
src/java.base/windows/native/libnio/ch/SocketDispatcher.c
test/jdk/java/net/Socket/asyncClose/BrokenPipe.java
--- a/src/java.base/windows/native/libnio/ch/SocketDispatcher.c	Fri Mar 01 15:05:33 2019 +0000
+++ b/src/java.base/windows/native/libnio/ch/SocketDispatcher.c	Fri Mar 01 17:40:16 2019 +0000
@@ -72,7 +72,11 @@
         if (theErr == WSAEWOULDBLOCK) {
             return IOS_UNAVAILABLE;
         }
-        JNU_ThrowIOExceptionWithLastError(env, "Read failed");
+        if (theErr == WSAECONNRESET) {
+            JNU_ThrowIOException(env, "Connection reset by peer");
+        } else {
+            JNU_ThrowIOExceptionWithLastError(env, "Read failed");
+        }
         return IOS_THROWN;
     }
 
@@ -128,7 +132,11 @@
         if (theErr == WSAEWOULDBLOCK) {
             return IOS_UNAVAILABLE;
         }
-        JNU_ThrowIOExceptionWithLastError(env, "Vector read failed");
+        if (theErr == WSAECONNRESET) {
+            JNU_ThrowIOException(env, "Connection reset by peer");
+        } else {
+            JNU_ThrowIOExceptionWithLastError(env, "Vector read failed");
+        }
         return IOS_THROWN;
     }
 
@@ -174,7 +182,11 @@
                if (theErr == WSAEWOULDBLOCK) {
                    return IOS_UNAVAILABLE;
                }
-               JNU_ThrowIOExceptionWithLastError(env, "Write failed");
+               if (theErr == WSAECONNRESET) {
+                   JNU_ThrowIOException(env, "Connection reset by peer");
+               } else {
+                   JNU_ThrowIOExceptionWithLastError(env, "Write failed");
+               }
                return IOS_THROWN;
             }
         }
@@ -256,7 +268,11 @@
         if (theErr == WSAEWOULDBLOCK) {
             return IOS_UNAVAILABLE;
         }
-        JNU_ThrowIOExceptionWithLastError(env, "Vector write failed");
+        if (theErr == WSAECONNRESET) {
+            JNU_ThrowIOException(env, "Connection reset by peer");
+        } else {
+            JNU_ThrowIOExceptionWithLastError(env, "Vector write failed");
+        }
         return IOS_THROWN;
     }
 
--- a/test/jdk/java/net/Socket/asyncClose/BrokenPipe.java	Fri Mar 01 15:05:33 2019 +0000
+++ b/test/jdk/java/net/Socket/asyncClose/BrokenPipe.java	Fri Mar 01 17:40:16 2019 +0000
@@ -69,7 +69,7 @@
              * replace this by catching a more specific exception.
              */
             String text = ioe.getMessage();
-            if (text.toLowerCase().indexOf("Socket closed") >= 0) {
+            if (text.toLowerCase().indexOf("closed") >= 0) {
                 throw ioe;
             }
         } finally {