Author: remy.maucherat(a)jboss.com
Date: 2014-01-23 07:44:12 -0500 (Thu, 23 Jan 2014)
New Revision: 2353
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java
Log:
Try to call onError if an error occurs during onClose.
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java 2014-01-23
12:15:22 UTC (rev 2352)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsSession.java 2014-01-23
12:44:12 UTC (rev 2353)
@@ -45,6 +45,7 @@
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
+import org.apache.tomcat.util.ExceptionUtils;
import org.jboss.web.WebsocketsLogger;
public class WsSession implements Session {
@@ -452,6 +453,9 @@
t.setContextClassLoader(applicationClassLoader);
try {
localEndpoint.onClose(this, closeReason);
+ } catch (Throwable throwable) {
+ ExceptionUtils.handleThrowable(throwable);
+ localEndpoint.onError(this, throwable);
} finally {
t.setContextClassLoader(cl);
}
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java
===================================================================
---
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java 2014-01-23
12:15:22 UTC (rev 2352)
+++
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoEndpointBase.java 2014-01-23
12:44:12 UTC (rev 2353)
@@ -96,8 +96,8 @@
methodMapping.getOnClose().invoke(pojo,
methodMapping.getOnCloseArgs(pathParameters, session,
closeReason));
} catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
WebsocketsLogger.ROOT_LOGGER.onCloseFailed(pojo.getClass().getName(),
t);
+ handleOnCloseError(session, t);
}
}
@@ -111,6 +111,19 @@
}
+ private void handleOnCloseError(Session session, Throwable t) {
+ // If really fatal - re-throw
+ ExceptionUtils.handleThrowable(t);
+
+ // Trigger the error handler and close the session
+ onError(session, t);
+ try {
+ session.close();
+ } catch (IOException ioe) {
+ WebsocketsLogger.ROOT_LOGGER.closeSessionFailed(ioe);
+ }
+ }
+
@Override
public final void onError(Session session, Throwable throwable) {
Show replies by date