[PATCH] 6350055: Atomic SelectionKey operations

Alan Bateman Alan.Bateman at oracle.com
Sun Jun 3 16:18:39 UTC 2018

On 31/05/2018 15:52, David Lloyd wrote:
> The testNioImplementation method covers IllegalArgumentException, but
> I can add tests for CancelledKeyException easily...
Thanks. I've taken the patch from your last mail to check on a number of 
points and also to do a bit of tweaking.

The javadoc is mostly okay. One thing that I may have missed in previous 
iterations is that you had interestOpsAnd declarig that it throws 
IllegalArgumentException. It doesn't of course as per the rational in 
the API note. Otherwise, I just moved the @apiNote and @implSpec to 
follow the method description and adjusted a few things to keep it as 
consistent with the existing spec and wording as possible.

Tests for SelectionKey are in the SelectionKey rather than Selector 
directory so I've moved the test there. Also we don't need 
"SelectionKey" in the name once it is moved.  I've also refactored the 
test so that the same tests can be exercised for both the default and 
default provider implementations. For example, you added added tests to 
check for IAE and CKE but these aren't tested for the default 
implementation. The test used a ConnectionPair to get a connected 
SocketChannel but this isn't needed as an unconnected SocketChannel can 
be registered with a Selector.

The patch changes the existing interestOps(int) to avoid queuing when 
the interest ops aren't changed. I was initially nervous about that for 
the case where a channel is initially registered with an interest set of 
0. I think I've satisfied myself that this is safe. I've run the tests 
on all platforms and all the tests are passing so that helps the 
confidence on that part.

I've put a webrev with the updated patch here:

If you are okay with these changes then the next step is the CSR.


More information about the nio-dev mailing list