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

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


The following commit(s) were added to refs/heads/10.0.x by this push:
     new 48cbc0f  Fix BZ 65342. Correct regression in fix for BZ 65262.
48cbc0f is described below

commit 48cbc0fc28cb3f80d09135fa07181c0b51454ba9
Author: Mark Thomas <ma...@apache.org>
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/jakarta/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/jakarta/websocket/server/ServerEndpointConfig.java 
b/java/jakarta/websocket/server/ServerEndpointConfig.java
index 4fb16d3..1b1a7e7 100644
--- a/java/jakarta/websocket/server/ServerEndpointConfig.java
+++ b/java/jakarta/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 0120845..3a37d66 100644
--- a/java/org/apache/tomcat/websocket/WsSession.java
+++ b/java/org/apache/tomcat/websocket/WsSession.java
@@ -75,7 +75,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 ba7c4b2..5e74509 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -191,6 +191,11 @@
         Update the <code>web-fragment.xml</code> included in
         <code>tomcat-websocket.jar</code>to use the Servlet 5.0 schema. (markt)
       </update>
+      <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 Jakarta WebSocket API. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">

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

Reply via email to