Skip to content

Commit 4b6a9ac

Browse files
committed
Polish WebSocketHttpRequestHandler
1 parent 4447248 commit 4b6a9ac

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ project("spring-websocket") {
505505
compile(project(":spring-core"))
506506
compile(project(":spring-context"))
507507
compile(project(":spring-web"))
508+
optional(project(":spring-webmvc"))
508509
optional("javax.servlet:javax.servlet-api:3.1.0")
509510
optional("javax.websocket:javax.websocket-api:1.0")
510511
optional("org.apache.tomcat:tomcat-websocket:8.0-SNAPSHOT") {

spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* {@link HttpServletResponse} to {@link ServerHttpRequest} and {@link ServerHttpResponse}
5050
* respectively.
5151
*
52-
* <p>The {@link #decorateWebSocketHandler(WebSocketHandler)} method decorates the given
52+
* <p>The {@link #applyDefaultDecorators(WebSocketHandler)} method decorates the given
5353
* WebSocketHandler with a logging and exception handling decorators. This method can
5454
* be overridden to change that.
5555
*
@@ -69,10 +69,10 @@ public WebSocketHttpRequestHandler(WebSocketHandler webSocketHandler) {
6969
this(webSocketHandler, new DefaultHandshakeHandler());
7070
}
7171

72-
public WebSocketHttpRequestHandler( WebSocketHandler webSocketHandler, HandshakeHandler handshakeHandler) {
73-
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
72+
public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) {
73+
Assert.notNull(wsHandler, "wsHandler must not be null");
7474
Assert.notNull(handshakeHandler, "handshakeHandler must not be null");
75-
this.wsHandler = decorateWebSocketHandler(webSocketHandler);
75+
this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler));
7676
this.handshakeHandler = handshakeHandler;
7777
}
7878

@@ -94,17 +94,6 @@ public List<HandshakeInterceptor> getHandshakeInterceptors() {
9494
return this.interceptors;
9595
}
9696

97-
/**
98-
* Decorate the WebSocketHandler provided to the class constructor.
99-
*
100-
* <p>By default {@link ExceptionWebSocketHandlerDecorator} and
101-
* {@link LoggingWebSocketHandlerDecorator} are applied are added.
102-
*/
103-
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler wsHandler) {
104-
wsHandler = new ExceptionWebSocketHandlerDecorator(wsHandler);
105-
return new LoggingWebSocketHandlerDecorator(wsHandler);
106-
}
107-
10897
@Override
10998
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
11099
throws ServletException, IOException {

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsHttpRequestHandler.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,10 @@ public SockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler ws
5555
Assert.notNull(sockJsService, "sockJsService must not be null");
5656
Assert.notNull(wsHandler, "webSocketHandler must not be null");
5757
this.sockJsService = sockJsService;
58-
this.wsHandler = decorateWebSocketHandler(wsHandler);
58+
this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler));
5959
}
6060

6161

62-
/**
63-
* Decorate the WebSocketHandler provided to the class constructor.
64-
*
65-
* <p>By default {@link ExceptionWebSocketHandlerDecorator} and
66-
* {@link LoggingWebSocketHandlerDecorator} are applied are added.
67-
*/
68-
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler wsHandler) {
69-
wsHandler = new ExceptionWebSocketHandlerDecorator(wsHandler);
70-
return new LoggingWebSocketHandlerDecorator(wsHandler);
71-
}
72-
7362
@Override
7463
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
7564
throws ServletException, IOException {

0 commit comments

Comments
 (0)