Skip to content

Commit 6eea4ad

Browse files
committed
Upgrade websocket module to servlet api 3.1.0
1 parent 7823c5d commit 6eea4ad

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ project("spring-websocket") {
493493
compile(project(":spring-core"))
494494
compile(project(":spring-context"))
495495
compile(project(":spring-web"))
496-
optional("javax.servlet:javax.servlet-api:3.1-b09")
496+
optional("javax.servlet:javax.servlet-api:3.1.0")
497497
optional("javax.websocket:javax.websocket-api:1.0")
498498
optional("org.apache.tomcat:tomcat-websocket:8.0-SNAPSHOT") {
499499
exclude group: "org.apache.tomcat", module: "tomcat-websocket-api"

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler;
3838
import org.glassfish.tyrus.websockets.Connection;
3939
import org.glassfish.tyrus.websockets.Version;
40+
import org.glassfish.tyrus.websockets.WebSocketApplication;
4041
import org.glassfish.tyrus.websockets.WebSocketEngine;
4142
import org.glassfish.tyrus.websockets.WebSocketEngine.WebSocketHolderListener;
4243
import org.springframework.http.HttpHeaders;
@@ -80,28 +81,28 @@ public void upgradeInternal(ServerHttpRequest request, ServerHttpResponse respon
8081
HttpServletResponse servletResponse = ((ServletServerHttpResponse) response).getServletResponse();
8182
servletResponse = new AlreadyUpgradedResponseWrapper(servletResponse);
8283

83-
TyrusEndpoint tyrusEndpoint = createTyrusEndpoint(servletRequest, endpoint, selectedProtocol);
84+
WebSocketApplication wsApp = createTyrusEndpoint(servletRequest, endpoint, selectedProtocol);
8485
WebSocketEngine engine = WebSocketEngine.getEngine();
8586

8687
try {
87-
engine.register(tyrusEndpoint);
88+
engine.register(wsApp);
8889
}
8990
catch (DeploymentException ex) {
9091
throw new HandshakeFailureException("Failed to deploy endpoint in GlassFish", ex);
9192
}
9293

9394
try {
94-
if (!performUpgrade(servletRequest, servletResponse, request.getHeaders(), tyrusEndpoint)) {
95+
if (!performUpgrade(servletRequest, servletResponse, request.getHeaders(), wsApp)) {
9596
throw new HandshakeFailureException("Failed to upgrade HttpServletRequest");
9697
}
9798
}
9899
finally {
99-
engine.unregister(tyrusEndpoint);
100+
engine.unregister(wsApp);
100101
}
101102
}
102103

103104
private boolean performUpgrade(HttpServletRequest request, HttpServletResponse response,
104-
HttpHeaders headers, TyrusEndpoint tyrusEndpoint) throws IOException {
105+
HttpHeaders headers, WebSocketApplication wsApp) throws IOException {
105106

106107
final TyrusHttpUpgradeHandler upgradeHandler;
107108
try {
@@ -114,7 +115,7 @@ private boolean performUpgrade(HttpServletRequest request, HttpServletResponse r
114115
Connection connection = createConnection(upgradeHandler, response);
115116

116117
RequestContext wsRequest = RequestContext.Builder.create()
117-
.requestURI(URI.create(tyrusEndpoint.getPath())).requestPath(tyrusEndpoint.getPath())
118+
.requestURI(URI.create(wsApp.getPath())).requestPath(wsApp.getPath())
118119
.connection(connection).secure(request.isSecure()).build();
119120

120121
for (String header : headers.keySet()) {
@@ -129,7 +130,8 @@ public void onWebSocketHolder(WebSocketEngine.WebSocketHolder webSocketHolder) {
129130
});
130131
}
131132

132-
private TyrusEndpoint createTyrusEndpoint(HttpServletRequest request, Endpoint endpoint, String selectedProtocol) {
133+
private WebSocketApplication createTyrusEndpoint(HttpServletRequest request,
134+
Endpoint endpoint, String selectedProtocol) {
133135

134136
// Use randomized path
135137
String requestUri = request.getRequestURI();

0 commit comments

Comments
 (0)