Skip to content

Commit 491adf1

Browse files
committed
Polishing
1 parent 0c2b787 commit 491adf1

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
5555

5656
private static final String METHOD_HEAD = "HEAD";
5757

58+
5859
/** Checking for Servlet 3.0+ HttpServletResponse.getStatus() */
5960
private static final boolean responseGetStatusAvailable =
6061
ClassUtils.hasMethod(HttpServletResponse.class, "getStatus");
6162

62-
6363
private boolean notModified = false;
6464

6565

@@ -184,7 +184,7 @@ public boolean checkNotModified(long lastModifiedTimestamp) {
184184
if (this.notModified && supportsNotModifiedStatus()) {
185185
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
186186
}
187-
if(response.getHeader(HEADER_LAST_MODIFIED) == null) {
187+
if (response.getHeader(HEADER_LAST_MODIFIED) == null) {
188188
response.setDateHeader(HEADER_LAST_MODIFIED, lastModifiedTimestamp);
189189
}
190190
}
@@ -193,12 +193,6 @@ public boolean checkNotModified(long lastModifiedTimestamp) {
193193
return this.notModified;
194194
}
195195

196-
private boolean isCompatibleWithConditionalRequests(HttpServletResponse response) {
197-
return response == null
198-
|| !responseGetStatusAvailable
199-
|| HttpStatus.valueOf(response.getStatus()).is2xxSuccessful();
200-
}
201-
202196
@SuppressWarnings("deprecation")
203197
private boolean isTimestampNotModified(long lastModifiedTimestamp) {
204198
long ifModifiedSince = -1;
@@ -233,7 +227,7 @@ public boolean checkNotModified(String etag) {
233227
if (this.notModified && supportsNotModifiedStatus()) {
234228
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
235229
}
236-
if(response.getHeader(HEADER_ETAG) == null) {
230+
if (response.getHeader(HEADER_ETAG) == null) {
237231
response.setHeader(HEADER_ETAG, etag);
238232
}
239233
}
@@ -242,6 +236,14 @@ public boolean checkNotModified(String etag) {
242236
return this.notModified;
243237
}
244238

239+
private boolean isCompatibleWithConditionalRequests(HttpServletResponse response) {
240+
if (response == null || !responseGetStatusAvailable) {
241+
// Can't check response.getStatus() - let's assume we're good
242+
return true;
243+
}
244+
return HttpStatus.valueOf(response.getStatus()).is2xxSuccessful();
245+
}
246+
245247
private String addEtagPadding(String etag) {
246248
if (!(etag.startsWith("\"") || etag.startsWith("W/\"")) || !etag.endsWith("\"")) {
247249
etag = "\"" + etag + "\"";
@@ -283,10 +285,10 @@ public boolean checkNotModified(String etag, long lastModifiedTimestamp) {
283285
if (this.notModified && supportsNotModifiedStatus()) {
284286
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
285287
}
286-
if(response.getHeader(HEADER_ETAG) == null) {
288+
if (response.getHeader(HEADER_ETAG) == null) {
287289
response.setHeader(HEADER_ETAG, etag);
288290
}
289-
if(response.getHeader(HEADER_LAST_MODIFIED) == null) {
291+
if (response.getHeader(HEADER_LAST_MODIFIED) == null) {
290292
response.setDateHeader(HEADER_LAST_MODIFIED, lastModifiedTimestamp);
291293
}
292294
}

spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebSphereRequestUpgradeStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -75,7 +75,7 @@ public void upgradeInternal(ServerHttpRequest httpRequest, ServerHttpResponse ht
7575
HttpServletResponse response = getHttpServletResponse(httpResponse);
7676

7777
StringBuffer requestUrl = request.getRequestURL();
78-
String path = request.getRequestURI(); // shouldn't matter
78+
String path = request.getRequestURI(); // shouldn't matter
7979
Map<String, String> pathParams = Collections.<String, String> emptyMap();
8080

8181
ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
@@ -88,7 +88,7 @@ public void upgradeInternal(ServerHttpRequest httpRequest, ServerHttpResponse ht
8888
}
8989
catch (Exception ex) {
9090
throw new HandshakeFailureException(
91-
"Servlet request failed to upgrade to WebSocket, uri=" + requestUrl, ex);
91+
"Servlet request failed to upgrade to WebSocket for " + requestUrl, ex);
9292
}
9393
}
9494

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
7676
private static final boolean undertowWsPresent = ClassUtils.isPresent(
7777
"io.undertow.websockets.jsr.ServerWebSocketContainer", classLoader);
7878

79-
private static final boolean glassFishWsPresent = ClassUtils.isPresent(
79+
private static final boolean glassfishWsPresent = ClassUtils.isPresent(
8080
"org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler", classLoader);
8181

82-
private static final boolean webLogicWsPresent = ClassUtils.isPresent(
82+
private static final boolean weblogicWsPresent = ClassUtils.isPresent(
8383
"weblogic.websocket.tyrus.TyrusServletWriter", classLoader);
8484

85-
private static final boolean webSphereWsPresent = ClassUtils.isPresent(
85+
private static final boolean websphereWsPresent = ClassUtils.isPresent(
8686
"com.ibm.websphere.wsoc.WsWsocServerContainer", classLoader);
8787

8888

@@ -125,13 +125,13 @@ else if (jettyWsPresent) {
125125
else if (undertowWsPresent) {
126126
className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy";
127127
}
128-
else if (glassFishWsPresent) {
128+
else if (glassfishWsPresent) {
129129
className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy";
130130
}
131-
else if (webLogicWsPresent) {
131+
else if (weblogicWsPresent) {
132132
className = "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy";
133133
}
134-
else if (webSphereWsPresent) {
134+
else if (websphereWsPresent) {
135135
className = "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy";
136136
}
137137
else {
@@ -368,7 +368,7 @@ protected final List<String> determineHandlerSupportedProtocols(WebSocketHandler
368368

369369
/**
370370
* Filter the list of requested WebSocket extensions.
371-
* <p>As of 4.1 the default implementation of this method filters the list to
371+
* <p>As of 4.1, the default implementation of this method filters the list to
372372
* leave only extensions that are both requested and supported.
373373
* @param request the current request
374374
* @param requestedExtensions the list of extensions requested by the client

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
*/
3939
public class DefaultHandshakeHandler extends AbstractHandshakeHandler implements ServletContextAware {
4040

41-
4241
public DefaultHandshakeHandler() {
4342
}
4443

0 commit comments

Comments
 (0)