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

markt 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 b0570e2  Fix BZ 65342. Correct regression in fix for BZ 65262.
b0570e2 is described below

commit b0570e20128a6bc314d552a40f46cbdeaa9a7dea
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Jun 1 13:53:09 2021 +0100

    Fix BZ 65342. Correct regression in fix for BZ 65262.
    
    The 'trick' used in BZ 65262 to identify if the end point is using the
    default ServerEndpointConfig implementation depended on implementation
    details of WebSocket API provided by Tomcat. This trick failed when
    using other WebSocket API JARs.
---
 java/javax/websocket/server/ServerEndpointConfig.java | 12 ++++++++++++
 java/org/apache/tomcat/websocket/WsSession.java       |  4 +++-
 webapps/docs/changelog.xml                            |  5 +++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/java/javax/websocket/server/ServerEndpointConfig.java 
b/java/javax/websocket/server/ServerEndpointConfig.java
index fa56ce4..6070a36 100644
--- a/java/javax/websocket/server/ServerEndpointConfig.java
+++ b/java/javax/websocket/server/ServerEndpointConfig.java
@@ -74,6 +74,18 @@ public interface ServerEndpointConfig extends EndpointConfig 
{
 
         private Builder(Class<?> endpointClass,
                 String path) {
+            if (endpointClass == null) {
+                throw new IllegalArgumentException("Endpoint class may not be 
null");
+            }
+            if (path == null) {
+                throw new IllegalArgumentException("Path may not be null");
+            }
+            if (path.isEmpty()) {
+                throw new IllegalArgumentException("Path may not be empty");
+            }
+            if (path.charAt(0) != '/') {
+                throw new IllegalArgumentException("Path must start with '/'");
+            }
             this.endpointClass = endpointClass;
             this.path = path;
         }
diff --git a/java/org/apache/tomcat/websocket/WsSession.java 
b/java/org/apache/tomcat/websocket/WsSession.java
index c090c20..8e83d1c 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -74,7 +74,9 @@ public class WsSession implements Session {
     private static AtomicLong ids = new AtomicLong(0);
 
     static {
-        ServerEndpointConfig.Builder builder = 
ServerEndpointConfig.Builder.create(null, null);
+        // Use fake end point and path. They are never used, they just need to
+        // be sufficient to pass the validation tests.
+        ServerEndpointConfig.Builder builder = 
ServerEndpointConfig.Builder.create(Object.class, "/");
         ServerEndpointConfig sec = builder.build();
         SEC_CONFIGURATOR_USES_IMPL_DEFAULT =
                 
sec.getConfigurator().getClass().equals(DefaultServerEndpointConfigurator.class);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6a2f068..ef85296 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -199,6 +199,11 @@
         size was an exact multiple of 8192. Based on a patch provided by 
Saksham
         Verma. (markt)
       </fix>
+      <fix>
+        <bug>65342</bug>: Correct a regression introduced with the fix for
+        <bug>65262</bug> that meant Tomcat's WebSocket implementation would 
only
+        work with Tomcat's implementation of the Java EE WebSocket API. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to