From bf38b3a4fc7752659750e504793fedc3b1c8dda8 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 23 May 2015 20:04:48 +0200 Subject: [PATCH] Polishing (cherry picked from commit 92bf32b) --- .../java/org/springframework/web/util/WebUtils.java | 12 +++++++----- .../standard/UndertowRequestUpgradeStrategy.java | 11 ++++++----- .../web/socket/sockjs/transport/SockJsSession.java | 9 +++++---- .../transport/session/AbstractSockJsSession.java | 8 ++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java index c5c5177d5e3..7e703788127 100644 --- a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java @@ -190,7 +190,7 @@ public abstract class WebUtils { * i.e. the value of the "defaultHtmlEscape" context-param in {@code web.xml} * (if any). Falls back to {@code false} in case of no explicit default given. * @param servletContext the servlet context of the web application - * @return whether default HTML escaping is enabled (default is false) + * @return whether default HTML escaping is enabled (default is {@code false}) * @deprecated as of Spring 4.1, in favor of {@link #getDefaultHtmlEscape} */ @Deprecated @@ -210,7 +210,8 @@ public abstract class WebUtils { * an actual boolean value specified, allowing to have a context-specific * default in case of no setting at the global level. * @param servletContext the servlet context of the web application - * @return whether default HTML escaping is enabled (null = no explicit default) + * @return whether default HTML escaping is enabled for the given application + * ({@code null} = no explicit default) */ public static Boolean getDefaultHtmlEscape(ServletContext servletContext) { if (servletContext == null) { @@ -230,7 +231,8 @@ public abstract class WebUtils { * an actual boolean value specified, allowing to have a context-specific * default in case of no setting at the global level. * @param servletContext the servlet context of the web application - * @return whether response encoding is used for HTML escaping (null = no explicit default) + * @return whether response encoding is to be used for HTML escaping + * ({@code null} = no explicit default) * @since 4.1.2 */ public static Boolean getResponseEncodedHtmlEscape(ServletContext servletContext) { @@ -749,7 +751,7 @@ public abstract class WebUtils { * keys {@code "q1"} and {@code "q2"} with values {@code ["a","b"]} and * {@code ["a","b","c"]} respectively. * @param matrixVariables the unparsed matrix variables string - * @return a map with matrix variable names and values, never {@code null} + * @return a map with matrix variable names and values (never {@code null}) * @since 3.2 */ public static MultiValueMap parseMatrixVariables(String matrixVariables) { @@ -779,7 +781,7 @@ public abstract class WebUtils { * Check the given request origin against a list of allowed origins. * A list containing "*" means that all origins are allowed. * An empty list means only same origin is allowed. - * @return true if the request origin is valid, false otherwise + * @return {@code true} if the request origin is valid, {@code false} otherwise * @since 4.1.5 * @see RFC 6454: The Web Origin Concept */ diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java index cb7000e50d8..679313dcfbd 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,11 +55,12 @@ import org.springframework.http.server.ServerHttpResponse; import org.springframework.util.ClassUtils; import org.springframework.web.socket.server.HandshakeFailureException; - /** * A {@link org.springframework.web.socket.server.RequestUpgradeStrategy} for use * with WildFly and its underlying Undertow web server. * + *

Compatible with Undertow 1.0, 1.1, 1.2 - as included in WildFly 8.x and 9.0. + * * @author Rossen Stoyanchev * @since 4.0.1 */ @@ -201,11 +202,11 @@ public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrat Collections., List>>emptyMap(), Collections., List>>emptyMap()); try { - return undertow11Present ? + return (undertow11Present ? endpointConstructor.newInstance(endpointRegistration, - new EndpointInstanceFactory(endpoint), null, encodingFactory, null) : + new EndpointInstanceFactory(endpoint), null, encodingFactory, null) : endpointConstructor.newInstance(endpointRegistration, - new EndpointInstanceFactory(endpoint), null, encodingFactory); + new EndpointInstanceFactory(endpoint), null, encodingFactory)); } catch (Exception ex) { throw new HandshakeFailureException("Failed to instantiate ConfiguredServerEndpoint", ex); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/SockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/SockJsSession.java index 080b2ea1e35..881844207f7 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/SockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/SockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,9 +34,10 @@ public interface SockJsSession extends WebSocketSession { long getTimeSinceLastActive(); /** - * Disable SockJS heartbeat, presumably because a higher level protocol has - * heartbeats enabled for the session. It is not recommended to disable this - * otherwise as it helps proxies to know the connection is not hanging. + * Disable the SockJS heartbeat, presumably because a higher-level protocol + * has heartbeats enabled for the session already. It is not recommended to + * disable this otherwise, as it helps proxies to know the connection is + * not hanging. */ void disableHeartbeat(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java index 8453e89d920..90351ba51b4 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ import org.springframework.web.socket.sockjs.transport.SockJsSession; */ public abstract class AbstractSockJsSession implements SockJsSession { - private static enum State {NEW, OPEN, CLOSED} + private enum State {NEW, OPEN, CLOSED} /** @@ -339,7 +339,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { catch (Throwable closeFailure) { // Nothing of consequence, already forced disconnect } - throw new SockJsTransportFailureException("Failed to write " + frame, this.getId(), ex); + throw new SockJsTransportFailureException("Failed to write " + frame, getId(), ex); } } @@ -360,7 +360,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { } } else { - logger.debug("Terminating connection after failure to send message to client.", failure); + logger.debug("Terminating connection after failure to send message to client", failure); } }