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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 6a70bc98ca Avoid unlikely NPE
6a70bc98ca is described below

commit 6a70bc98ca027cff19d0fab161192ccb2438ff40
Author: remm <r...@apache.org>
AuthorDate: Wed Sep 20 11:10:02 2023 +0200

    Avoid unlikely NPE
    
    This would occur if the filter is already registered, which would be
    highly unexpected but assume all is well.
    Found by coverity.
---
 java/org/apache/tomcat/websocket/server/WsServerContainer.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/server/WsServerContainer.java 
b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
index b33fa50bda..8fb4eb967c 100644
--- a/java/org/apache/tomcat/websocket/server/WsServerContainer.java
+++ b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
@@ -89,11 +89,13 @@ public class WsServerContainer extends WsWebSocketContainer 
implements ServerCon
         }
 
         FilterRegistration.Dynamic fr = servletContext.addFilter("Tomcat 
WebSocket (JSR356) Filter", new WsFilter());
-        fr.setAsyncSupported(true);
+        if (fr != null) {
+            fr.setAsyncSupported(true);
 
-        EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST, 
DispatcherType.FORWARD);
+            EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST, 
DispatcherType.FORWARD);
 
-        fr.addMappingForUrlPatterns(types, true, "/*");
+            fr.addMappingForUrlPatterns(types, true, "/*");
+        }
     }
 
 


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

Reply via email to