Code review request 7132889: Possible race conditions in AbstractSelectableChannel

Shirish Kuncolienkar shirishk at linux.vnet.ibm.com
Tue Aug 7 02:34:23 PDT 2012


Could I get this change reviewed please

code inspection of the AbstractSelectableChannel class shows that a 
timing window exists between the channel close and cancellation of the 
key. Which can lead to following consequences
1. Selector registered on this channel can select the key while the 
channel is closed or is being closed
2. A new key can be added to the channel while the it is closed or is 
being closed
3. configureBlocking() can be invoked while the channel is closed or is 
being closed

One might be able to construct a testcase using a test-specific subclass 
of AbstractSelectableChannel, which has a synchronization point in its 
implementation of implCloseSelectableChannel() so that tests can be 
performed there. However, it would be quite an involved thing to write 
with clarity.

I have created a patch under http://cr.openjdk.java.net/~luchsh/7132889/



More information about the nio-dev mailing list