On Tue, 5 May 2026 16:28:45 GMT, Jaikiran Pai <[email protected]> wrote:
>> src/java.base/share/classes/java/net/Socket.java line 1756:
>>
>>> 1754: * independent of each other. Irrespective of whether or not the
>>> socket
>>> 1755: * is {@linkplain #close() closed}, this method will return
>>> {@code true} only
>>> 1756: * if a prior call to {@link #shutdownInput()} completed
>>> successfully.
>>
>> It might be simpler to have one sentence to say that this method will return
>> true for a closed socket if was shutdown for input before the socket was
>> closed. That would avoid mentioning "write-half" and closed state.
>
> The initial change in this PR was a one sentence description of this method:
>
>>
>> {@linkplain #close() Closing} a socket doesn't clear its read-half shutdown
>> state,
>> which means this method will return {@code true}
>> for a closed socket if {@linkplain #shutdownInput() shutdownInput()}
>> completed successfully prior to the socket being closed.
>
> We decided to make it a bit more verbose to clarify what it really means
> https://github.com/openjdk/jdk/pull/31000#discussion_r3168263753. I would
> need some help with the specific text if this needs to be trimmed down. Would
> you have something that we could use here?
We came up with wording for SocketChannel.shutdownInput and maybe the first
sentence from that method could be copied over to Socket.shutdownInput
(replacing "channel" with "socket" of course). We can also expand the `@throws`
description to specify that it throws if the Socket is shutdown for reading.
If we improved shutdownInput then it would allow the description of
isShutdownInput to be re-specified to say that it returns true if the Socket
was shutdown for reading with the shutdownInput method.
Invoking isInputXXX methods on a closed Socket is a bit of a corner case and we
should be able to specify it in a single sentence, like we do already with the
isConnected method, e.g. "this method will return true for a closed socket if
it was shutdown for reading prior to being closed".
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31000#discussion_r3190136687