You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/06/25 17:05:58 UTC

svn commit: r1496511 - in /tomcat/trunk/java/org/apache/tomcat/websocket/pojo: LocalStrings.properties PojoMethodMapping.java

Author: markt
Date: Tue Jun 25 15:05:58 2013
New Revision: 1496511

URL: http://svn.apache.org/r1496511
Log:
Fix failing tests. Duplicate annotation test was wrong.

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=1496511&r1=1496510&r2=1496511&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties Tue Jun 25 15:05:58 2013
@@ -19,7 +19,7 @@ pojoEndpointBase.onErrorFail=Failed to c
 pojoEndpointBase.onOpenFail=Failed to call onOpen method of POJO end point for POJO of type [{0}]
 pojoEndpointServer.getPojoInstanceFail=Failed to create instance of POJO of type [{0}]
 pojoMethodMapping.decodePathParamFail=Failed to decode path parameter value [{0}] to expected type [{1}]
-pojoMethodMapping.duplicateAnnotation=Duplicate annotations present on class [{0}]
+pojoMethodMapping.duplicateAnnotation=Duplicate annotations [{0}] present on class [{1}]
 pojoMethodMapping.duplicateLastParam=Multiple boolean (last) parameters present on the method [{0}] of class [{1}] that was annotated with OnMessage
 pojoMethodMapping.duplicateMessageParam=Multiple message parameters present on the method [{0}] of class [{1}] that was annotated with OnMessage
 pojoMethodMapping.duplicatePongMessageParam=Multiple PongMessage 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=1496511&r1=1496510&r2=1496511&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java Tue Jun 25 15:05:58 2013
@@ -79,21 +79,37 @@ public class PojoMethodMapping {
         Method close = null;
         Method error = null;
         for (Method method : clazzPojo.getMethods()) {
-            if (open == null &&
-                    method.getAnnotation(OnOpen.class) != null) {
-                open = method;
-            } else if (close == null &&
-                    method.getAnnotation(OnClose.class) != null) {
-                close = method;
-            } else if (error == null &&
-                    method.getAnnotation(OnError.class) != null) {
-                error = method;
+            if (method.getAnnotation(OnOpen.class) != null) {
+                if (open == null) {
+                    open = method;
+                } else {
+                    // Duplicate annotation
+                    throw new DeploymentException(sm.getString(
+                            "pojoMethodMapping.duplicateAnnotation",
+                            OnOpen.class, clazzPojo));
+                }
+            } else if (method.getAnnotation(OnClose.class) != null) {
+                if (close == null) {
+                    close = method;
+                } else {
+                    // Duplicate annotation
+                    throw new DeploymentException(sm.getString(
+                            "pojoMethodMapping.duplicateAnnotation",
+                            OnClose.class, clazzPojo));
+                }
+            } else if (method.getAnnotation(OnError.class) != null) {
+                if (error == null) {
+                    error = method;
+                } else {
+                    // Duplicate annotation
+                    throw new DeploymentException(sm.getString(
+                            "pojoMethodMapping.duplicateAnnotation",
+                            OnError.class, clazzPojo));
+                }
             } else if (method.getAnnotation(OnMessage.class) != null) {
                 onMessage.add(new MessageMethod(method, decoders));
             } else {
-                // Duplicate annotation
-                throw new DeploymentException(sm.getString(
-                        "pojoMethodMapping.duplicateAnnotation", clazzPojo));
+                // Method not annotated
             }
         }
         this.onOpen = open;



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