Review Request : JDK-8002306, (se) Selector.open fails if invoked with thread interrupt status set [win]
David M. Lloyd
david.lloyd at redhat.com
Mon Dec 10 14:51:38 PST 2012
On 12/10/2012 04:28 PM, Dan Xu wrote:
> Hi folks,
> Please help review the fix for JDK-8002306, Selector.open fails if
> invoked with thread interrupt status set [win], at
> On windows, we establish loopback socket connections every time a
> selector is opened. But the connect operation will fail and throw out
> ClosedByInterruptException if its current thread is interrupted. In
> order to open a selector on an interrupted thread successfully, the fix
> clears the interrupt status, establish socket connections, and reset the
> status to interrupt afterwards to work around the restrictions. Thanks!
There will still be a race where the thread interrupt status could be
set after it was cleared but before the selector is created.
I think there are probably only two viable options here:
1. Treat the current behavior as "correct": you cannot open a selector
when the current thread is interrupted.
2. Rewrite the selector open operation such that it creates the socket
without respecting the state of the interrupted flag.
More information about the nio-dev