RFR for JDK-8027212: java/nio/channels/Selector/SelectAfterRead.java fails intermittently

Alan Bateman Alan.Bateman at oracle.com
Tue Nov 19 02:36:17 PST 2013


On 19/11/2013 06:25, Eric Wang wrote:
> Hi everyone,
>
> I'm working on the bug 
> https://bugs.openjdk.java.net/browse/JDK-8027212. after research, it 
> is a test failure.
> Root Cause:
> The test is based on bad assumption that the ByteServer thread has 
> finished to write bytes to client before the client SelectAfterRead 
> calls selector.select(TIMEOUT)(TIMEOUT=1000).
>
> Suggested Fix:
> Use CountDownLatch to sync up server and client, The fix looks like 
> below, Please let me know if you have any comments or suggestions.
Thanks Eric, I think your analysis that the 1000ms is insufficient is 
right (unfortunately some of the tests from the JDK 1.4 era had issues 
like this).

We can fix this in several ways. Using a CountDownLatch is okay here but 
it might be simpler for await to do serverthread.join() because the 
server thread ends when it has written the bytes.

What you would think about doing a few other clean-ups to ByteServer? 
For example the start method shouldn't do a System.exit if it gets an 
exception Also several of the fields can be final.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20131119/09c4a642/attachment.html 


More information about the nio-dev mailing list