On Wed, 6 May 2026 13:40:07 GMT, Jaikiran Pai <[email protected]> wrote:
>> Can I please get a review of this doc-only change which updates the >> specification of `Socket.isInputShutdown()` and `Socket.isOutputShutdown()` >> to clarify how it behaves when the `Socket` has been closed? >> >> This addresses https://bugs.openjdk.org/browse/JDK-8310138. The commit in >> this PR merely specifies the current implementation. I'll create a CSR >> shortly. >> >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Jaikiran Pai has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase. The pull request contains six additional > commits since the last revision: > > - Reword the shutdownInput/Output and isInput/OutputShutdown() methods > - merge latest from master branch > - merge latest from master branch > - link instead of linkplain > - improve the text > - 8310138 Socket.isInputShutdown and isOutputShutdown don't specify what is > returned when socket is closed src/java.base/share/classes/java/net/Socket.java line 1667: > 1665: * <p> > 1666: * If you write to a socket {@code OutputStream} after invoking > this method, > 1667: * the stream will throw an {@code IOException}. A separate detail we might want to discuss is whether the `NioSocketImpl` in its write() implementation should detect a `isOutputClosed` and throw an `IOException` from the Java code instead of issuing a native write call and then throwing the exception from there. What I mean is, in the current implementation, it's the native code which throws this IOException. Here's an example: jshell> var s = new Socket("127.0.0.1", 8000) s ==> Socket[addr=/127.0.0.1,port=8000,localport=12345] jshell> OutputStream os = s.getOutputStream() os ==> java.net.Socket$SocketOutputStream@3830f1c0 jshell> s.shutdownOutput() jshell> os.write(0x42) | Exception java.net.SocketException: Broken pipe | at SocketDispatcher.write0 (Native Method) | at SocketDispatcher.write (SocketDispatcher.java:65) | at NioSocketImpl.tryWrite (NioSocketImpl.java:408) | at NioSocketImpl.implWrite (NioSocketImpl.java:425) | at NioSocketImpl.write (NioSocketImpl.java:458) | at NioSocketImpl$2.write (NioSocketImpl.java:825) | at Socket$SocketOutputStream.implWrite (Socket.java:1097) | at Socket$SocketOutputStream.write (Socket.java:1087) | at Socket$SocketOutputStream.write (Socket.java:1082) | at (#11:1) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/31000#discussion_r3195905566
