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

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


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

commit dff67ffe0841196416f9ed20f2232d519cfbaf53
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 5de039f838..1ef2a41c6a 100644
--- a/java/org/apache/tomcat/websocket/server/WsServerContainer.java
+++ b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
@@ -96,11 +96,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