You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2015/02/24 17:45:34 UTC
svn commit: r1662018 -
/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
Author: remm
Date: Tue Feb 24 16:45:34 2015
New Revision: 1662018
URL: http://svn.apache.org/r1662018
Log:
Add NPE avoidance code from NIO2 when a socket is concurrently closed. Maybe it could be logged for debugging (same in NIO2).
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1662018&r1=1662017&r2=1662018&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Tue Feb 24 16:45:34 2015
@@ -1681,6 +1681,9 @@ public class NioEndpoint extends Abstrac
@Override
public void run() {
NioChannel socket = ka.getSocket();
+ if (socket == null) {
+ return;
+ }
SelectionKey key = socket.getIOChannel().keyFor(
socket.getPoller().getSelector());
@@ -1704,7 +1707,7 @@ public class NioEndpoint extends Abstrac
int handshake = -1;
try {
- if (key != null) {
+ if (key != null && socket != null) {
// For STOP there is no point trying to handshake as the
// Poller has been stopped.
if (socket.isHandshakeComplete() ||
@@ -1761,13 +1764,15 @@ public class NioEndpoint extends Abstrac
}
}
} else if (handshake == -1 ) {
- if (key != null) {
- socket.getPoller().cancelledKey(key);
- }
- if (running && !paused) {
- nioChannels.push(socket);
+ if (socket != null) {
+ if (key != null) {
+ socket.getPoller().cancelledKey(key);
+ }
+ if (running && !paused) {
+ nioChannels.push(socket);
+ }
+ socket = null;
}
- socket = null;
if (running && !paused) {
keyCache.push(ka);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org