JDK-6878250 : (so) IllegalBlockingModeException thrown when reading from a closed SocketChannel's InputStream
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 6u13,openjdk8u282
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: x86
  • Submitted: 2009-09-02
  • Updated: 2021-05-04
  • Resolved: 2021-03-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjdk8u302 b01Fixed
Related Reports
Duplicate :  
Relates :  
Description
Connect a non-blocking SocketChannel to a server and get the associated Socket. From the Socket get the associated InputStream. Close the SocketChannel and then read from the InputStream. A ClosedChannelException is expected but instead we get an IllegalBlockingModeException. While it is true that the blocking mode is illegal, the SocketChannel being closed, the blocking mode is unimportant for a read() operation.

When the SocketChannel is in blocking mode, the correct exception (ClosedChannelException) is thrown.

A sample application that reproduces this problem is attached.

Seen on:
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)

Comments
URL: https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/389dd8689b82 User: andrew Date: 2021-05-04 20:08:37 +0000
04-05-2021

URL: https://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/rev/389dd8689b82 User: fyang Date: 2021-03-02 15:25:52 +0000
02-03-2021

Fix Request [8u] https://mail.openjdk.java.net/pipermail/jdk8u-dev/2021-March/013479.html
02-03-2021

This issue has been fixed in JDK 11u by backporting JDK-8246707. Adding a link and adding 11-na due to this.
25-02-2021

Sorry, I made a mistake about the review process. I re-sent the email in jdk8u-dev. The patch of 11u has been reviewed and merged. https://hg.openjdk.java.net/jdk-updates/jdk11u-dev/rev/c4ee7dea3686
25-02-2021

Has this been reviewed for 8u? I don't see a review on that thread. The jdk8u-fix-request label should only be added when the patch has been reviewed by an OpenJDK 8u reviewer and is ready for approval. Also, in this case, the 11u version should be reviewed, approved and integrated before 8u. Replacing label with jdk8u-needs-review.
04-02-2021

Fix Request [8u] https://mail.openjdk.java.net/pipermail/nio-dev/2021-February/008123.html
03-02-2021

JDK-8260875 is another report of this issue. The adaptor was significantly changed in JDK 13, including throw ClosedChannelException rather than IllegalBlockingModeException when the adapter is called to read from an input stream for a channel that was configured non-blocking before it was closed.
02-02-2021

This issue suggests that there is a bug in the directory server as you can't do stream/blocking I/O with a channel that is configured non-blocking. That said, the blocking mode is undefined once the channel is closed and it may be more helpful to throw ClosedChannelException here.
28-02-2018