Author: markt Date: Thu Apr 24 08:11:30 2014 New Revision: 1589631 URL: http://svn.apache.org/r1589631 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56449 When creating a new session, add the message handlers to the session before calling Endpoint.onOpen() so the message handlers are in place should the onOpen() method trigger the sending of any messages.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1589630 Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java?rev=1589631&r1=1589630&r2=1589631&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java Thu Apr 24 08:11:30 2014 @@ -53,6 +53,14 @@ public abstract class PojoEndpointBase e Object pojo = getPojo(); Map<String,String> pathParameters = getPathParameters(); + // Add message handlers before calling onOpen since that may trigger a + // message which in turn could trigger a response and/or close the + // session + for (MessageHandler mh : methodMapping.getMessageHandlers(pojo, + pathParameters, session, config)) { + session.addMessageHandler(mh); + } + if (methodMapping.getOnOpen() != null) { try { methodMapping.getOnOpen().invoke(pojo, @@ -75,11 +83,6 @@ public abstract class PojoEndpointBase e return; } } - - for (MessageHandler mh : methodMapping.getMessageHandlers(pojo, - pathParameters, session, config)) { - session.addMessageHandler(mh); - } } Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1589631&r1=1589630&r2=1589631&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Apr 24 08:11:30 2014 @@ -173,6 +173,12 @@ client connections initiated by web applications but stand alone clients must call <code>WsWebSocketContainer.destroy()</code>. (markt) </fix> + <fix> + <bug>56449</bug>: When creating a new session, add the message handlers + to the session before calling <code>Endpoint.onOpen()</code> so the + message handlers are in place should the <code>onOpen()</code> method + trigger the sending of any messages. (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