Community
Participate
Working Groups
When a SocketChannel is closed by the network the TCPSelector calls TCPConnector.handleRead(). There a ClosedChannelException is caught and the connector is deactivated. This deactivation causes all channels of the connector being deactivated, as well as the protocols of the channels. All these deactivations can additionally cause various listeners being called. If any of these calls involve blocking I/O, e.g. new RequestWithConfirmation().send(), a deadlock will occur because this IO would need the TCPSelector to serve the I/O request. This can never happen because the TCPSelector is already blocked on the request.
Created attachment 179431 [details] Patch v1 - for future reference The fix involves asynchronous deactivation of TCPConnectors and TCPAcceptors when the SocketChannel has been closed by the network. Note: It's important to cancel the selection key immediately before scheduling the final deactivation!
Committed to HEAD
Available in R20110608-1407