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/10/16 13:25:14 UTC
svn commit: r1532728 - in /tomcat/tc7.0.x/trunk: ./
java/org/apache/tomcat/websocket/WsSession.java
Author: markt
Date: Wed Oct 16 11:25:13 2013
New Revision: 1532728
URL: http://svn.apache.org/r1532728
Log:
Don't call the onError() method of the endpoint if the WebSocket close message cannot be sent for abnormal closure as this is not unexpected.
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1532722
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1532728&r1=1532727&r2=1532728&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/WsSession.java Wed Oct 16 11:25:13 2013
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHa
import java.util.concurrent.atomic.AtomicLong;
import javax.websocket.CloseReason;
+import javax.websocket.CloseReason.CloseCode;
import javax.websocket.CloseReason.CloseCodes;
import javax.websocket.DeploymentException;
import javax.websocket.Endpoint;
@@ -464,7 +465,8 @@ public class WsSession implements Sessio
private void sendCloseMessage(CloseReason closeReason) {
// 125 is maximum size for the payload of a control message
ByteBuffer msg = ByteBuffer.allocate(125);
- msg.putShort((short) closeReason.getCloseCode().getCode());
+ CloseCode closeCode = closeReason.getCloseCode();
+ msg.putShort((short) closeCode.getCode());
String reason = closeReason.getReasonPhrase();
if (reason != null && reason.length() > 0) {
@@ -481,7 +483,13 @@ public class WsSession implements Sessio
log.debug(sm.getString("wsSession.sendCloseFail"), ioe);
}
wsRemoteEndpoint.close();
- localEndpoint.onError(this, ioe);
+ // Failure to send a close message is not unexpected in the case of
+ // an abnormal closure (usually triggered by a failure to read/write
+ // from/to the client. In this case do not trigger the endpoint's
+ // error handling
+ if (closeCode != CloseCodes.CLOSED_ABNORMALLY) {
+ localEndpoint.onError(this, ioe);
+ }
} finally {
webSocketContainer.unregisterSession(localEndpoint, this);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org