Author: markt
Date: Wed Jun 26 21:09:11 2013
New Revision: 1497098
URL: http://svn.apache.org/r1497098
Log:
WebSocket 1.0, Section 4.3
Invalid use of @PathParam should trigger a deployment error
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
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=1497098&r1=1497097&r2=1497098&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties
Wed Jun 26 21:09:11 2013
@@ -25,8 +25,10 @@ pojoMethodMapping.duplicateMessageParam=
pojoMethodMapping.duplicatePongMessageParam=Multiple PongMessage parameters
present on the method [{0}] of class [{1}] that was annotated with OnMessage
pojoMethodMapping.duplicateSessionParam=Multiple session parameters present on
the method [{0}] of class [{1}] that was annotated with OnMessage
pojoMethodMapping.invalidDecoder=The specified decoder of type [{0}] could not
be instantiated
+pojoMethodMapping.invalidPathParamType=Parameters annotated with @PathParam
may only be Strings, Java primitives or a boxed version thereof
pojoMethodMapping.noPayload=No payload parameter present on the method [{0}]
of class [{1}] that was annotated with OnMessage
pojoMethodMapping.onErrorNoThrowable=No Throwable parameter was present on the
method [{0}] of class [{1}] that was annotated with OnError
+pojoMethodMapping.paramWithoutAnnotation=A parameter of type [{0}] was found
on method[{1}] of class [{2}] that did not have a @PathParam annotation
pojoMethodMapping.partialInputStream=Invalid InputStream and boolean
parameters present on the method [{0}] of class [{1}] that was annotated with
OnMessage
pojoMethodMapping.partialObject=Invalid Object and boolean parameters present
on the method [{0}] of class [{1}] that was annotated with OnMessage
pojoMethodMapping.partialPong=Invalid PongMesssge and boolean parameters
present on the method [{0}] of class [{1}] that was annotated with OnMessage
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=1497098&r1=1497097&r2=1497098&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java
Wed Jun 26 21:09:11 2013
@@ -175,7 +175,7 @@ public class PojoMethodMapping {
private static PojoPathParam[] getPathParams(Method m,
- MethodType methodType) {
+ MethodType methodType) throws DeploymentException {
if (m == null) {
return new PojoPathParam[0];
}
@@ -202,6 +202,15 @@ public class PojoMethodMapping {
for (Annotation paramAnnotation : paramAnnotations) {
if (paramAnnotation.annotationType().equals(
PathParam.class)) {
+ // Check that the type is valid. "0" coerces to every
+ // valid type
+ try {
+ Util.coerceToType(type, "0");
+ } catch (IllegalArgumentException iae) {
+ throw new DeploymentException(sm.getString(
+ "pojoMethodMapping.invalidPathParamType"),
+ iae);
+ }
result[i] = new PojoPathParam(type,
((PathParam) paramAnnotation).value());
break;
@@ -209,12 +218,14 @@ public class PojoMethodMapping {
}
// Parameters without annotations are not permitted
if (result[i] == null) {
- throw new IllegalArgumentException();
+ throw new DeploymentException(sm.getString(
+ "pojoMethodMapping.paramWithoutAnnotation",
+ type, m.getName(), m.getClass().getName()));
}
}
}
if (methodType == MethodType.ON_ERROR && !foundThrowable) {
- throw new IllegalArgumentException(sm.getString(
+ throw new DeploymentException(sm.getString(
"pojoMethodMapping.onErrorNoThrowable",
m.getName(), m.getDeclaringClass().getName()));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]