FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2 (Pentium 4, hyperthreading)
A DESCRIPTION OF THE PROBLEM :
The documentation for Selector describes precisely when a call to select() will return, i.e. "at least one channel is selected, this selector's wakeup method is invoked, or the current thread is interrupted, whichever comes first."
I found two scenario where select() returns 0 without blocking, forever:
- When a channel registers with the Selector with an interest set of 0.
- When a socket channel that had not completed the connection process (invoking finishConnect until returning true) is registered with READ/WRITE interest set without CONNECT.
This behaviour is not consistent with the doc, maybe it can be considered a bug, or maybe the doc should change.
This bug can be reproduced always.