JDK-8146298 : (dc spec) connect and disconnect methods should specify that they may block
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8u66,9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-12-28
  • Updated: 2020-02-12
  • Resolved: 2019-11-14
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.
JDK 14
14 b24Fixed
Related Reports
Blocks :  
CSR :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
while the documentation of other methods of this class mentions if the respective method may block,
the docu for disconnect() does not mention it at all, and it even states:
"If this channel's socket is not connected, or if the channel is closed, then invoking this method has no effect."
which is not true if one considers blocking as an effect, which i think most people would.

http://docs.oracle.com/javase/8/docs/api/java/nio/channels/DatagramChannel.html#disconnect--


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
junit test: https://gist.github.com/hoijui/e77f5d276b6b3c29b123
---------- END SOURCE ----------


Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/de56632f796d User: bpb Date: 2019-11-14 17:19:34 +0000
14-11-2019

connect and disconnect may need to block waiting for I/O operations to complete. The "This method may be invoked at any time ..." paragraph in these methods needs to be re-worked.
30-10-2019

Attached the test case provided by the submitter to the bug report. http://docs.oracle.com/javase/8/docs/api/java/nio/channels/DatagramChannel.html#disconnect--
30-12-2015