JDK-5046333 : (so) Can no longer accept from a non-blocking server-socket channel's socket
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_redhat_3.0,solaris_9
  • CPU: x86,sparc
  • Submitted: 2004-05-12
  • Updated: 2017-05-16
  • Resolved: 2004-05-28
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
5.0 b54Fixed
Related Reports
Relates :  
Description
While the current jdk code "may" be working correctly, this is a behavior
change from previous releases.

In 1.4.2 and previous releases of nio.channels, you were able to
create a non-blocking socket from a non-blocking server socket 
channel using:
       Socket s = channel.socket().accept();

This call now returns:
   java.nio.channels.IllegalBlockingModeException
        at sun.nio.ch.ServerSocketAdaptor.accept(ServerSocketAdaptor.java:81)
        at SimpleServer.run(SimpleServer.java:55)
        at java.lang.Thread.run(Thread.java:595)

It appears that the socket created is not looking at the non-blocking
state of the server socket.

Creating a channel, then a socket works correctly (see workaround)

See attached testcase

To duplicate the problem:
   Start the simple server application:
        java SimpleServer

   Telnet to the server:
        telnet localhost 7676

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-rc FIXED IN: tiger-rc INTEGRATED IN: tiger-b54 tiger-rc
14-06-2004

WORK AROUND Use: SocketChannel sc = channel.accept(); Socket s = sc.socket();
11-06-2004

EVALUATION The observed change is an inadvertent consequence of the fix for 4801882. According to the specification the code fragment channel.socket().accept() should never have worked for non-blocking server-socket channels, but in fact it has worked since 1.4.0 so long as the socket is bound and there is a connection ready to be accepted. In order to maintain binary compatibility we'll revise the specification of the ServerSocket.accept method to allow the original behavior and adjust the fix for 4801882 accordingly. -- ###@###.### 2004/5/17
05-12-0183