Hi, I got the following error in a Tomcat 9.0.37 installation: WARNING [http-apr-8081-Poller] org.apache.tomcat.util.net.AprEndpoint$Poller.run Unexpected poller error java.lang.NullPointerException at org.apache.tomcat.util.net.AprEndpoint.processSocket(AprEndpoint.java:725) at org.apache.tomcat.util.net.AprEndpoint$Poller.run(AprEndpoint.java:1453) at java.base/java.lang.Thread.run(Thread.java:834) It is running on Java 11, so there is no additional information provided about which variable was null. The system is usually running okay, so I do not expect misconfiguration.
The problem is that "socketWrapper" is null at https://github.com/apache/tomcat/blob/9.0.x/java/org/apache/tomcat/util/net/AprEndpoint.java#L725 SocketWrapperBase<Long> socketWrapper = connections.get(Long.valueOf(socket)); if (event == SocketEvent.OPEN_READ && socketWrapper.readOperation != null) { All other places where connections.get(...) is used there is a check for non-null. I am not sure what kind of result should be returned: - false - indicating there is a problem - throw RuntimeException
With HTTP/1.1 this would be unusual and indicate a possible application bug (retaining references beyond the object's lifecycle). With HTTP/2, WebSocket etc. it is possible that the socket is closed in one thread while the socket is still in the Poller. There is a fairly narrow window in which this NPE can occur. Returning false is sufficient in this instance. I'll fix this shortly.
Fixed in: - master for 10.0.0-M8 onwards - 9.0.x for 9.0.38 onwards - 8.5.x for 8.5.58 onwards The equivalent test was already present in 7.0.x