Bug 52926 - NPE in processSocket
NPE in processSocket
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Connectors
7.0.25
PC Linux
: P2 critical with 2 votes (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-03-16 08:19 UTC by Morten Haraldsen
Modified: 2015-10-25 18:35 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Morten Haraldsen 2012-03-16 08:19:25 UTC
We have sporadic issues triggering 502 proxy errors using the NIO connector behind Nginx, caused by dropped connections/end of streams in Tomcat. The Tomcat log shows:

SEVERE: Error allocating socket processor
java.lang.NullPointerException 
at org.apache.tomcat.util.net.NioEndpoint.processSocket(NioEndpoint.java:721)
at org.apache.tomcat.util.net.NioEndpoint$Poller.cancelledKey(NioEndpoint.java:1048)
at org.apache.tomcat.util.net.NioEndpoint$Poller.timeout(NioEndpoint.java:1392)
at org.apache.tomcat.util.net.NioEndpoint$Poller.run(NioEndpoint.java:1174)
at java.lang.Thread.run(Thread.java:662)

Looking at the code in processSocket I see the line in NioEndpoint(721): 
attachment.setCometNotify(false); //will get reset upon next reg

Attachment is fetched in line 720:
KeyAttachment attachment = (KeyAttachment)socket.getAttachment(false);

Looking at socket.getAttachement() method I see that this method is indeed capable of returning null, but no null-check for this is done (although it is in multiple other locations, so it seems inconsistent).
Comment 1 Mark Thomas 2012-03-20 11:11:14 UTC
Thanks for the report. Fixed in trunk and 7.0.x and will be included in 7.0.27 onwards.
Comment 2 Konstantin Kolinko 2015-10-25 18:35:12 UTC
This fix (r1302839) was backported to Tomcat 6 in r1710473 and will be in 6.0.45 onwards.