Author: markt
Date: Thu Jan 31 15:08:15 2019
New Revision: 1852604
URL: http://svn.apache.org/viewvc?rev=1852604&view=rev
Log:
Implement the requirements of section 4.3 of the WebSocket 1.1 specification
and ensure that the deployment of an Endpoint fails if @PathParam is used with
an invalid parameter type.
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoPathParam.java
tomcat/trunk/webapps/docs/changelog.xml
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties?rev=1852604&r1=1852603&r2=1852604&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
[UTF-8] (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
[UTF-8] Thu Jan 31 15:08:15 2019
@@ -41,3 +41,5 @@ pojoMethodMapping.partialObject=Invalid
pojoMethodMapping.partialPong=Invalid PongMessage and boolean parameters
present on the method [{0}] of class [{1}] that was annotated with OnMessage
pojoMethodMapping.partialReader=Invalid Reader and boolean parameters present
on the method [{0}] of class [{1}] that was annotated with OnMessage
pojoMethodMapping.pongWithPayload=Invalid PongMessage and Message parameters
present on the method [{0}] of class [{1}] that was annotated with OnMessage
+
+pojoPathParam.wrongType=The type [{0}] is not permitted as a path parameter.
Must be String, primitive or boxed version of primitive
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java?rev=1852604&r1=1852603&r2=1852604&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
Thu Jan 31 15:08:15 2019
@@ -388,7 +388,9 @@ public class PojoMethodMapping {
private DecoderMatch decoderMatch = null;
private long maxMessageSize = -1;
- public MessageHandlerInfo(Method m, List<DecoderEntry> decoderEntries)
{
+ public MessageHandlerInfo(Method m, List<DecoderEntry> decoderEntries)
+ throws DeploymentException {
+
this.m = m;
Class<?>[] types = m.getParameterTypes();
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoPathParam.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoPathParam.java?rev=1852604&r1=1852603&r2=1852604&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoPathParam.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoPathParam.java Thu
Jan 31 15:08:15 2019
@@ -16,6 +16,11 @@
*/
package org.apache.tomcat.websocket.pojo;
+import javax.websocket.DeploymentException;
+
+import org.apache.tomcat.util.res.StringManager;
+import org.apache.tomcat.websocket.Util;
+
/**
* Stores the parameter type and name for a parameter that needs to be passed
to
* an onXxx method of {@link javax.websocket.Endpoint}. The name is only
present
@@ -26,11 +31,14 @@ package org.apache.tomcat.websocket.pojo
*/
public class PojoPathParam {
+ private static final StringManager sm =
StringManager.getManager(PojoPathParam.class);
+
private final Class<?> type;
private final String name;
- public PojoPathParam(Class<?> type, String name) {
+ public PojoPathParam(Class<?> type, String name) throws
DeploymentException {
+ validateType(type);
this.type = type;
this.name = name;
}
@@ -44,4 +52,15 @@ public class PojoPathParam {
public String getName() {
return name;
}
+
+
+ private static void validateType(Class<?> type) throws DeploymentException
{
+ if (String.class == type) {
+ return;
+ }
+ if (Util.isPrimitive(type)) {
+ return;
+ }
+ throw new DeploymentException(sm.getString("pojoPathParam.wrongType",
type.getName()));
+ }
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1852604&r1=1852603&r2=1852604&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Jan 31 15:08:15 2019
@@ -206,6 +206,11 @@
specification and ensure that if the deployment of one Endpoint fails,
no Endpoints are deployed for that web application. (markt)
</fix>
+ <fix>
+ Implement the requirements of section 4.3 of the WebSocket 1.1
+ specification and ensure that the deployment of an Endpoint fails if
+ <code>@PathParam</code> is used with an invalid parameter type. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]