This is an automated email from the ASF dual-hosted git repository.
markt 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 c39dd74 Fix BZ 65342. Correct regression in fix for BZ 65262.
c39dd74 is described below
commit c39dd7460413a9d9a9c1b5c3b680827b5dcd63b7
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 696e519..b878095 100644
--- a/java/javax/websocket/server/ServerEndpointConfig.java
+++ b/java/javax/websocket/server/ServerEndpointConfig.java
@@ -75,6 +75,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 2a6e035..061575c 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -187,6 +187,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]