This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 717387f Add dedicated handling and warn for a null socket channel
717387f is described below
commit 717387f9df4a933f18a3f44ded685300002b33eb
Author: remm <[email protected]>
AuthorDate: Wed Oct 28 10:46:43 2020 +0100
Add dedicated handling and warn for a null socket channel
The cause of the null socket channel is unknown at this time.
---
java/org/apache/tomcat/util/net/LocalStrings.properties | 1 +
java/org/apache/tomcat/util/net/NioEndpoint.java | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index 5d6237d..a6a376a 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -96,6 +96,7 @@ endpoint.launch.fail=Failed to launch new runnable
endpoint.nio.keyProcessingError=Error processing selection key
endpoint.nio.latchMustBeZero=Latch must be at count zero or null
endpoint.nio.nullLatch=Latch cannot be null
+endpoint.nio.nullSocketChannel=Invalid null socket channel while processing
poller event
endpoint.nio.pollerEventError=Error processing poller event
endpoint.nio.registerFail=Failed to register socket with selector from poller
endpoint.nio.selectorCloseFail=Failed to close selector when closing the poller
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index c7edd6d..ac4959e 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -542,16 +542,22 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
for (int i = 0, size = events.size(); i < size && (pe =
events.poll()) != null; i++ ) {
result = true;
NioChannel channel = pe.getSocket();
+ SocketChannel sc = channel.getIOChannel();
NioSocketWrapper socketWrapper = channel.getSocketWrapper();
int interestOps = pe.getInterestOps();
- if (interestOps == OP_REGISTER) {
+ if (sc == null) {
+ log.warn(sm.getString("endpoint.nio.nullSocketChannel"));
+ if (socketWrapper != null) {
+ socketWrapper.close();
+ }
+ } else if (interestOps == OP_REGISTER) {
try {
- channel.getIOChannel().register(getSelector(),
SelectionKey.OP_READ, socketWrapper);
+ sc.register(getSelector(), SelectionKey.OP_READ,
socketWrapper);
} catch (Exception x) {
log.error(sm.getString("endpoint.nio.registerFail"),
x);
}
} else {
- final SelectionKey key =
channel.getIOChannel().keyFor(getSelector());
+ final SelectionKey key = sc.keyFor(getSelector());
if (key == null) {
// The key was cancelled (e.g. due to socket closure)
// and removed from the selector while it was being
@@ -571,7 +577,7 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
cancelledKey(key, socketWrapper);
}
} else {
- cancelledKey(key, null);
+ cancelledKey(key, socketWrapper);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]