Remove synchronized block around WebSocketSession.send

Since we now wrap the WebSocketSession with a concurrent decorator, the
synchronized keyword around message sending needed to be removed.

Issue: SPR-11586
This commit is contained in:
Rossen Stoyanchev 2014-03-21 11:42:23 -04:00
parent 796af90ba7
commit 299be08268
3 changed files with 8 additions and 5 deletions

View File

@ -118,6 +118,11 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
}
private void checkSessionLimits() throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Another send already in progress, session id '" + getId() + "'" +
", in-progress send time " + getInProgressSendTime() + " (ms), " +
", buffer size " + this.bufferSize + " bytes");
}
if (getInProgressSendTime() > this.sendTimeLimit) {
logError("A message could not be sent due to a timeout");
getDelegate().close();

View File

@ -198,11 +198,9 @@ public class StompSubProtocolHandler implements SubProtocolHandler {
try {
message = MessageBuilder.withPayload(message.getPayload()).setHeaders(headers).build();
byte[] bytes = this.stompEncoder.encode((Message<byte[]>) message);
TextMessage textMessage = new TextMessage(bytes);
synchronized(session) {
session.sendMessage(new TextMessage(bytes));
}
session.sendMessage(textMessage);
}
catch (Throwable ex) {
sendErrorMessage(session, ex);

View File

@ -174,7 +174,7 @@ public class WebSocketServerSockJsSession extends AbstractSockJsSession implemen
@Override
protected void disconnect(CloseStatus status) throws IOException {
if (this.webSocketSession != null) {
if (isActive()) {
this.webSocketSession.close(status);
}
}