Project: Tomcat
Bug 50467 Occasional NIO connector lockups on high load
Reported: 2010-12-13 14:02:35 | Status: resolved fixed

We've been running Tomcat 6.0.29 on FC8 2.6.21 with tens of thousands of long polling threads which usually work fine. Every few days though we will experience a sudden lockup of the NIO connector and it has to be restarted. These have been seen to be accompanied by the following stack trace: Exception in thread "http-8082-ClientPoller-0" java.lang.NullPointerException at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:1620) at java.lang.Thread.run(Thread.java:662) Looking at the source it seems the issue is likely to be a race condition where access() is called on a null attachment, probably while it's in the process of being cancelled: while (iterator != null && iterator.hasNext()) { SelectionKey sk = (SelectionKey) iterator.next(); KeyAttachment attachment = (KeyAttachment)sk.attachment(); /*NPE*/ attachment.access(); iterator.remove(); processKey(sk, attachment); }//while

Files changed in fix:
java/org/apache/tomcat/util/net/NioEndpoint.java