JDK-6295054 : (se) PollSelector loses more events than DevPollSelector when SelectionKeys used across threads
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 5.0u2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_9
  • CPU: generic
  • Submitted: 2005-07-08
  • Updated: 2010-05-09
  • Resolved: 2007-01-16
Related Reports
Duplicate :  
Relates :  
Description
Possibly we are on illegal territory with the premise for this problem: updating the events of interest for a SelectionKey while another thread is sleeping in a poll on that key.

This update works using the DevPollSelector.

While  "it works using DevPoll" does not make it right, it would offer less surprise to the programmer if we had the as much as possible the same behaviour in each implementation.  Plus, implementing the simple list of udpates is straightforward.

While we warn in the API docs that Selectors are safe to use in multiple threads but their keys are not, it would be nice to make as much as possible of this API safe across multiple threads.  Also, from reading the API document it's not 100% clear that what we are doing is illegal: we are only updating a key's interest events in one thread at once.


###@###.### 2005-07-08 16:32:55 GMT
###@###.### 2005-07-11 18:13:17 GMT

Comments
EVALUATION This turns out to be the same issue as 6240230 which will be addressed in jdk7 as a side effect of the fix for 6429204. As the /dev/poll based Selector is the default on Solaris this should not impact customers.
26-05-2006

SUGGESTED FIX sun/nio/ch/PollArrayWrapper.java in attached jar file contains an example change using a LinkedList similarly to DevPollArrayWrapper.java , whose updates are processed before a call to poll. Customer's testcase attached: once the startup scripts are edited for paths, we can reproduce a lockup where the events of interest are "lost" and the main thread hangs in poll forever. This problem goes away when using (e.g via -Xbootclasspath/p:./PollArrayWrapper.jar ) the attached class. ###@###.### 2005-07-08 16:32:56 GMT
08-07-2005