Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50467
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Jan 2011 13:51:48 +0000 (13:51 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Jan 2011 13:51:48 +0000 (13:51 +0000)
Protect against NPE that will cause Poller to fail

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1055458 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/NioEndpoint.java
webapps/docs/changelog.xml

index 095afcb..e377121 100644 (file)
@@ -1141,9 +1141,15 @@ public class NioEndpoint extends AbstractEndpoint {
                     while (iterator != null && iterator.hasNext()) {
                         SelectionKey sk = iterator.next();
                         KeyAttachment attachment = (KeyAttachment)sk.attachment();
-                        attachment.access();
-                        iterator.remove();
-                        processKey(sk, attachment);
+                        // Attachment may be null if another thread has called
+                        // cancelledKey()
+                        if (attachment == null) {
+                            iterator.remove();
+                        } else {
+                            attachment.access();
+                            iterator.remove();
+                            processKey(sk, attachment);
+                        }
                     }//while
 
                     //process timeouts
index 3c331b9..f655372 100644 (file)
         Remove a huge memory leak in the NIO connector introduced by the fix
         for <bug>49884</bug>. (markt)
       </fix>
+      <fix>
+        <bug>50467</bug>: Protected against NPE triggered by a race condition
+        that causes the NIO poller to fail, preventing the processing of further
+        requests. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">