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

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


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

commit 3e87f4980cb8d4a399be85305eaee8a6e1baf268
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 f69fcff620..06afbee06d 100644
--- a/java/org/apache/tomcat/websocket/server/WsServerContainer.java
+++ b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
@@ -97,11 +97,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