Remove synchronized keywords from SockJsSession impls
Before this change SockJsSession implementations of WebSocketSession used synchronization around its method implementations protecting internal state and ensuring only a single thread is sending messages at a time. A WebSocketSession is generally expected to be used from one thread at a time and now that application messages are sent through ConcurrentWebSocketSessionDecorator, there is no concern about application messages sent from the different threads. While there are some remaining concerns, those can be addressed without using the synchronized keyword. This change removes it from the methods of all SockJS session implementations. Issue: SPR-11450
This commit is contained in:
@@ -81,9 +81,6 @@ public class HttpSockJsSessionTests extends AbstractSockJsSessionTests<TestAbstr
|
||||
|
||||
this.session.handleInitialRequest(this.request, this.response, this.frameFormat);
|
||||
|
||||
assertTrue(this.session.hasRequest());
|
||||
assertTrue(this.session.hasResponse());
|
||||
|
||||
assertEquals("hhh\no", this.servletResponse.getContentAsString());
|
||||
assertFalse(this.servletRequest.isAsyncStarted());
|
||||
|
||||
@@ -96,8 +93,6 @@ public class HttpSockJsSessionTests extends AbstractSockJsSessionTests<TestAbstr
|
||||
this.session.getMessageCache().add("x");
|
||||
this.session.handleSuccessiveRequest(this.request, this.response, this.frameFormat);
|
||||
|
||||
assertTrue(this.session.hasRequest());
|
||||
assertTrue(this.session.hasResponse());
|
||||
assertTrue(this.servletRequest.isAsyncStarted());
|
||||
|
||||
assertTrue(this.session.wasHeartbeatScheduled());
|
||||
@@ -125,8 +120,8 @@ public class HttpSockJsSessionTests extends AbstractSockJsSessionTests<TestAbstr
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writePrelude() throws IOException {
|
||||
getResponse().getBody().write("hhh\n".getBytes());
|
||||
protected void writePrelude(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
|
||||
response.getBody().write("hhh\n".getBytes());
|
||||
}
|
||||
|
||||
public boolean wasCacheFlushed() {
|
||||
@@ -137,14 +132,6 @@ public class HttpSockJsSessionTests extends AbstractSockJsSessionTests<TestAbstr
|
||||
return this.heartbeatScheduled;
|
||||
}
|
||||
|
||||
public boolean hasRequest() {
|
||||
return getRequest() != null;
|
||||
}
|
||||
|
||||
public boolean hasResponse() {
|
||||
return getResponse() != null;
|
||||
}
|
||||
|
||||
public void setExceptionOnWriteFrame(IOException exceptionOnWriteFrame) {
|
||||
this.exceptionOnWriteFrame = exceptionOnWriteFrame;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user