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 2026/01/05 16:05:18 UTC

(tomcat) branch 11.0.x updated: Avoid possible NPE

This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 8d63578901 Avoid possible NPE
8d63578901 is described below

commit 8d6357890101d175b0b6a6e54d8e233098a301e5
Author: remm <re...@apache.org>
AuthorDate: Mon Jan 5 17:03:38 2026 +0100

    Avoid possible NPE
    
    Resetting the socket leads to possible concurrency issues that are hard
    to eliminate.
---
 java/org/apache/tomcat/util/net/NioChannel.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/NioChannel.java b/java/org/apache/tomcat/util/net/NioChannel.java
index 672f3a664a..5c3eb2af36 100644
--- a/java/org/apache/tomcat/util/net/NioChannel.java
+++ b/java/org/apache/tomcat/util/net/NioChannel.java
@@ -54,7 +54,11 @@ public class NioChannel implements ByteChannel, ScatteringByteChannel, Gathering
      * @throws IOException If a problem was encountered resetting the channel
      */
     public void reset(SocketChannel channel, NioSocketWrapper socketWrapper) throws IOException {
-        this.sc = channel;
+        // Don't reset socket on null as it can lead to NPEs
+        if (channel != null) {
+            this.sc = channel;
+        }
+        // Resetting socketWrapper is possible
         this.socketWrapper = socketWrapper;
         bufHandler.reset();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org