# HG changeset patch # User alanb # Date 1551462016 0 # Node ID a0ad3ffd7b601b441658e54acb69f04f2c6984fe # Parent 510cfa1184087c9c588a33e72d9ba9bc846002b3 Have connection reset by peer message be same as PlainSocketImpl diff -r 510cfa118408 -r a0ad3ffd7b60 src/java.base/windows/native/libnio/ch/SocketDispatcher.c --- 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; } diff -r 510cfa118408 -r a0ad3ffd7b60 test/jdk/java/net/Socket/asyncClose/BrokenPipe.java --- 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 {