Skip to content

Commit

Permalink
Socket.getInputStream()'s JavaDocs explain behavior of skip for timeo…
Browse files Browse the repository at this point in the history
…ut, non-blocking, interrupt
  • Loading branch information
mkarg committed Oct 27, 2024
1 parent 1525444 commit ecc32c1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/java.base/share/classes/java/net/Socket.java
Original file line number Diff line number Diff line change
Expand Up @@ -1010,18 +1010,19 @@ public SocketChannel getChannel() {
*
* <p> If this socket has an associated channel then the resulting input
* stream delegates all of its operations to the channel. If the channel
* is in non-blocking mode then the input stream's {@code read} operations
* will throw an {@link java.nio.channels.IllegalBlockingModeException}.
* is in non-blocking mode then the input stream's {@code read} and
* {@code skip} operations will throw an
* {@link java.nio.channels.IllegalBlockingModeException}.
*
* <p> Reading from the input stream is {@linkplain Thread#interrupt()
* interruptible} in the following circumstances:
* <ol>
* <li> The socket is {@linkplain SocketChannel#socket() associated} with
* a {@link SocketChannel SocketChannel}.
* In that case, interrupting a thread reading from the input stream
* will close the underlying channel and cause the read method to
* throw {@link ClosedByInterruptException} with the interrupt
* status set.
* will close the underlying channel and cause the read and skip
* methods to throw {@link ClosedByInterruptException} with the
* interrupt status set.
* <li> The socket uses the system-default socket implementation and a
* {@linkplain Thread#isVirtual() virtual thread} is reading from the
* input stream. In that case, interrupting the virtual thread will
Expand Down Expand Up @@ -1410,6 +1411,9 @@ public boolean getOOBInline() throws SocketException {
* The option <B>must</B> be enabled prior to entering the blocking operation
* to have effect.
*
* <p> Behavior of any other method call on the InputStream associated with
* this Socket is implementation specific.
*
* @param timeout the specified timeout, in milliseconds.
* @throws SocketException if there is an error in the underlying protocol,
* such as a TCP error, or the socket is closed.
Expand Down

0 comments on commit ecc32c1

Please sign in to comment.