diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java index fff10682957..68a621419f2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/JdkDynamicAopProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -75,7 +75,7 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa */ /** We use a static Log to avoid serialization issues */ - private static Log logger = LogFactory.getLog(JdkDynamicAopProxy.class); + private static final Log logger = LogFactory.getLog(JdkDynamicAopProxy.class); /** Config used to configure this proxy */ private final AdvisedSupport advised; diff --git a/spring-context/src/main/java/org/springframework/validation/ValidationUtils.java b/spring-context/src/main/java/org/springframework/validation/ValidationUtils.java index 9da8e3d26b8..5db89a4c5df 100644 --- a/spring-context/src/main/java/org/springframework/validation/ValidationUtils.java +++ b/spring-context/src/main/java/org/springframework/validation/ValidationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -38,7 +38,7 @@ import org.springframework.util.StringUtils; */ public abstract class ValidationUtils { - private static Log logger = LogFactory.getLog(ValidationUtils.class); + private static final Log logger = LogFactory.getLog(ValidationUtils.class); /** diff --git a/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java index 73dbe2c8eb6..cc09fd80d3c 100644 --- a/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java @@ -54,7 +54,7 @@ import org.springframework.util.ClassUtils; */ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameDiscoverer { - private static Log logger = LogFactory.getLog(LocalVariableTableParameterNameDiscoverer.class); + private static final Log logger = LogFactory.getLog(LocalVariableTableParameterNameDiscoverer.class); // marker object for classes that do not have any debug info private static final Map NO_DEBUG_INFO_MAP = Collections.emptyMap(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java index eeab9cc9eba..2df8b1fd468 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java @@ -63,7 +63,7 @@ public class EmbeddedDatabaseFactory { */ public static final String DEFAULT_DATABASE_NAME = "testdb"; - private static Log logger = LogFactory.getLog(EmbeddedDatabaseFactory.class); + private static final Log logger = LogFactory.getLog(EmbeddedDatabaseFactory.class); private String databaseName = DEFAULT_DATABASE_NAME; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java index 5e7aff6bc8e..4c8059f4de4 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -32,7 +32,7 @@ import org.springframework.util.Assert; */ public class HandlerMethodReturnValueHandlerComposite implements HandlerMethodReturnValueHandler { - private static Log logger = LogFactory.getLog(HandlerMethodReturnValueHandlerComposite.class); + private static final Log logger = LogFactory.getLog(HandlerMethodReturnValueHandlerComposite.class); private final List returnValueHandlers = new ArrayList(); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributes.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributes.java index 8a9a14e272b..a0ed1a9816f 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributes.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributes.java @@ -33,18 +33,16 @@ import java.util.Map; */ public class SimpAttributes { - private static Log logger = LogFactory.getLog(SimpAttributes.class); - - private static final String className = SimpAttributes.class.getName(); - /** Key for the mutex session attribute */ - public static final String SESSION_MUTEX_NAME = className + ".MUTEX"; + public static final String SESSION_MUTEX_NAME = SimpAttributes.class.getName() + ".MUTEX"; /** Key set after the session is completed */ - public static final String SESSION_COMPLETED_NAME = className + ".COMPLETED"; + public static final String SESSION_COMPLETED_NAME = SimpAttributes.class.getName() + ".COMPLETED"; /** Prefix for the name of session attributes used to store destruction callbacks. */ - public static final String DESTRUCTION_CALLBACK_NAME_PREFIX = className + ".DESTRUCTION_CALLBACK."; + public static final String DESTRUCTION_CALLBACK_NAME_PREFIX = SimpAttributes.class.getName() + ".DESTRUCTION_CALLBACK."; + + private static final Log logger = LogFactory.getLog(SimpAttributes.class); private final String sessionId; @@ -54,7 +52,6 @@ public class SimpAttributes { /** * Constructor wrapping the given session attributes map. - * * @param sessionId the id of the associated session * @param attributes the attributes */ @@ -66,27 +63,8 @@ public class SimpAttributes { } - /** - * Extract the SiMP session attributes from the given message, wrap them in - * a {@link SimpAttributes} instance. - * - * @param message the message to extract session attributes from - */ - public static SimpAttributes fromMessage(Message message) { - Assert.notNull(message); - MessageHeaders headers = message.getHeaders(); - String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); - Map sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(headers); - if (sessionId == null || sessionAttributes == null) { - throw new IllegalStateException( - "Message does not contain SiMP session id or attributes: " + message); - } - return new SimpAttributes(sessionId, sessionAttributes); - } - /** * Return the value for the attribute of the given name, if any. - * * @param name the name of the attribute * @return the current attribute value, or {@code null} if not found */ @@ -96,7 +74,6 @@ public class SimpAttributes { /** * Set the value with the given name replacing an existing value (if any). - * * @param name the name of the attribute * @param value the value for the attribute */ @@ -106,12 +83,10 @@ public class SimpAttributes { /** * Remove the attribute of the given name, if it exists. - * *

Also removes the registered destruction callback for the specified * attribute, if any. However it does not execute the callback. * It is assumed the removed object will continue to be used and destroyed * independently at the appropriate time. - * * @param name the name of the attribute */ public void removeAttribute(String name) { @@ -121,7 +96,6 @@ public class SimpAttributes { /** * Retrieve the names of all attributes. - * * @return the attribute names as String array, never {@code null} */ public String[] getAttributeNames() { @@ -131,7 +105,6 @@ public class SimpAttributes { /** * Register a callback to execute on destruction of the specified attribute. * The callback is executed when the session is closed. - * * @param name the name of the attribute to register the callback for * @param callback the destruction callback to be executed */ @@ -152,7 +125,6 @@ public class SimpAttributes { /** * Return an id for the associated session. - * * @return the session id as String (never {@code null}) */ public String getSessionId() { @@ -161,7 +133,6 @@ public class SimpAttributes { /** * Expose the object to synchronize on for the underlying session. - * * @return the session mutex to use (never {@code null}) */ public Object getSessionMutex() { @@ -197,13 +168,29 @@ public class SimpAttributes { try { ((Runnable) entry.getValue()).run(); } - catch (Throwable t) { - if (logger.isErrorEnabled()) { - logger.error("Uncaught error in session attribute destruction callback", t); - } + catch (Throwable ex) { + logger.error("Uncaught error in session attribute destruction callback", ex); } } } } + + /** + * Extract the SiMP session attributes from the given message, wrap them in + * a {@link SimpAttributes} instance. + * @param message the message to extract session attributes from + */ + public static SimpAttributes fromMessage(Message message) { + Assert.notNull(message); + MessageHeaders headers = message.getHeaders(); + String sessionId = SimpMessageHeaderAccessor.getSessionId(headers); + Map sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(headers); + if (sessionId == null || sessionAttributes == null) { + throw new IllegalStateException( + "Message does not contain SiMP session id or attributes: " + message); + } + return new SimpAttributes(sessionId, sessionAttributes); + } + } diff --git a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java index 38879158544..30875ce3215 100644 --- a/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java +++ b/spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/AsyncRequestInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -44,7 +44,7 @@ import java.util.concurrent.Callable; public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter implements DeferredResultProcessingInterceptor { - private static Log logger = LogFactory.getLog(AsyncRequestInterceptor.class); + private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class); private final SessionFactory sessionFactory; @@ -52,11 +52,13 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte private volatile boolean timeoutInProgress; + public AsyncRequestInterceptor(SessionFactory sessionFactory, SessionHolder sessionHolder) { this.sessionFactory = sessionFactory; this.sessionHolder = sessionHolder; } + @Override public void preProcess(NativeWebRequest request, Callable task) { bindSession(); @@ -90,11 +92,17 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte } } + // Implementation of DeferredResultProcessingInterceptor methods - public void beforeConcurrentHandling(NativeWebRequest request, DeferredResult deferredResult) { } - public void preProcess(NativeWebRequest request, DeferredResult deferredResult) { } - public void postProcess(NativeWebRequest request, DeferredResult deferredResult, Object result) { } + public void beforeConcurrentHandling(NativeWebRequest request, DeferredResult deferredResult) { + } + + public void preProcess(NativeWebRequest request, DeferredResult deferredResult) { + } + + public void postProcess(NativeWebRequest request, DeferredResult deferredResult, Object result) { + } @Override public boolean handleTimeout(NativeWebRequest request, DeferredResult deferredResult) { @@ -106,4 +114,5 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte public void afterCompletion(NativeWebRequest request, DeferredResult deferredResult) { closeAfterTimeout(); } + } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java b/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java index 046bd8f6501..eabd41ecb44 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/support/AsyncRequestInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -44,7 +44,7 @@ import java.util.concurrent.Callable; public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter implements DeferredResultProcessingInterceptor { - private static Log logger = LogFactory.getLog(AsyncRequestInterceptor.class); + private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class); private final EntityManagerFactory emFactory; @@ -58,6 +58,7 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte this.emHolder = emHolder; } + @Override public void preProcess(NativeWebRequest request, Callable task) { bindSession(); @@ -91,11 +92,17 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte } } + // Implementation of DeferredResultProcessingInterceptor methods - public void beforeConcurrentHandling(NativeWebRequest request, DeferredResult deferredResult) { } - public void preProcess(NativeWebRequest request, DeferredResult deferredResult) { } - public void postProcess(NativeWebRequest request, DeferredResult deferredResult, Object result) { } + public void beforeConcurrentHandling(NativeWebRequest request, DeferredResult deferredResult) { + } + + public void preProcess(NativeWebRequest request, DeferredResult deferredResult) { + } + + public void postProcess(NativeWebRequest request, DeferredResult deferredResult, Object result) { + } @Override public boolean handleTimeout(NativeWebRequest request, DeferredResult deferredResult) { @@ -107,5 +114,5 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte public void afterCompletion(NativeWebRequest request, DeferredResult deferredResult) { closeAfterTimeout(); } -} +} diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java b/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java index ba3885330d0..3cf4f889f89 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/CallableInterceptorChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -31,7 +31,7 @@ import org.springframework.web.context.request.NativeWebRequest; */ class CallableInterceptorChain { - private static Log logger = LogFactory.getLog(CallableInterceptorChain.class); + private static final Log logger = LogFactory.getLog(CallableInterceptorChain.class); private final List interceptors; @@ -102,4 +102,5 @@ class CallableInterceptorChain { } } } + } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultInterceptorChain.java b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultInterceptorChain.java index ffe9bb81265..fba37f178a0 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultInterceptorChain.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultInterceptorChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -29,7 +29,7 @@ import org.springframework.web.context.request.NativeWebRequest; */ class DeferredResultInterceptorChain { - private static Log logger = LogFactory.getLog(DeferredResultInterceptorChain.class); + private static final Log logger = LogFactory.getLog(DeferredResultInterceptorChain.class); private final List interceptors; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyAdviceChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyAdviceChain.java index d673c6983d5..2368d969f3e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyAdviceChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyAdviceChain.java @@ -35,7 +35,7 @@ import java.util.List; */ class ResponseBodyAdviceChain { - private static Log logger = LogFactory.getLog(ResponseBodyAdviceChain.class); + private static final Log logger = LogFactory.getLog(ResponseBodyAdviceChain.class); private final List advice; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java index 45a30ab8029..1bc4417eb93 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java @@ -42,7 +42,7 @@ import org.springframework.web.filter.OncePerRequestFilter; */ public class ResourceUrlEncodingFilter extends OncePerRequestFilter { - private static Log logger = LogFactory.getLog(ResourceUrlEncodingFilter.class); + private static final Log logger = LogFactory.getLog(ResourceUrlEncodingFilter.class); @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java index 5a32c0d36e7..fbca2ff04ca 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java @@ -16,12 +16,6 @@ package org.springframework.web.socket.handler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.WebSocketMessage; -import org.springframework.web.socket.WebSocketSession; - import java.io.IOException; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; @@ -29,6 +23,13 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.springframework.web.socket.CloseStatus; +import org.springframework.web.socket.WebSocketMessage; +import org.springframework.web.socket.WebSocketSession; + /** * Wraps a {@link org.springframework.web.socket.WebSocketSession} and guarantees @@ -44,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock; */ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorator { - private static Log logger = LogFactory.getLog(ConcurrentWebSocketSessionDecorator.class); + private static final Log logger = LogFactory.getLog(ConcurrentWebSocketSessionDecorator.class); private final Queue> buffer = new LinkedBlockingQueue>(); @@ -61,7 +62,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat private volatile boolean limitExceeded; - private volatile boolean shutDownInProgress; + private volatile boolean shutdownInProgress; private final Lock flushLock = new ReentrantLock(); @@ -87,7 +88,6 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat public void sendMessage(WebSocketMessage message) throws IOException { - if (isDisabled()) { return; } @@ -110,7 +110,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat } private boolean isDisabled() { - return (this.limitExceeded || this.shutDownInProgress); + return (this.limitExceeded || this.shutdownInProgress); } private boolean tryFlushMessageBuffer() throws IOException { @@ -140,17 +140,13 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat if (!isDisabled() && this.closeLock.tryLock()) { try { if (getTimeSinceSendStarted() > this.sendTimeLimit) { - String errorMessage = "Message send time " + getTimeSinceSendStarted() + " (ms) exceeded the allowed limit " + this.sendTimeLimit; - sessionLimitReached(errorMessage, CloseStatus.SESSION_NOT_RELIABLE); } else if (this.bufferSize.get() > this.bufferSizeLimit) { - String errorMessage = "The send buffer size " + this.bufferSize.get() + " bytes for " + "session '" + getId() + " exceeded the allowed limit " + this.bufferSizeLimit; - sessionLimitReached(errorMessage, (getTimeSinceSendStarted() >= 10000 ? CloseStatus.SESSION_NOT_RELIABLE : null)); } @@ -168,7 +164,8 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat @Override public void close(CloseStatus status) throws IOException { - this.shutDownInProgress = true; + this.shutdownInProgress = true; super.close(status); } + } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java index f5e9f17691c..48b394b9c26 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java @@ -57,7 +57,7 @@ import org.springframework.util.ReflectionUtils; */ public class ServerEndpointExporter implements InitializingBean, BeanPostProcessor, ApplicationContextAware { - private static Log logger = LogFactory.getLog(ServerEndpointExporter.class); + private static final Log logger = LogFactory.getLog(ServerEndpointExporter.class); private final List> annotatedEndpointClasses = new ArrayList>(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java index 9ee7cb77487..31a54287e0b 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -45,23 +45,21 @@ import org.springframework.web.context.WebApplicationContext; * * @author Rossen Stoyanchev * @since 4.0 - * * @see ServerEndpointExporter */ public class SpringConfigurator extends Configurator { - private static Log logger = LogFactory.getLog(SpringConfigurator.class); + private static final String NO_VALUE = ObjectUtils.identityToString(new Object()); + + private static final Log logger = LogFactory.getLog(SpringConfigurator.class); private static final Map, String>> cache = new ConcurrentHashMap, String>>(); - private static final String NO_VALUE = ObjectUtils.identityToString(new Object()); - @SuppressWarnings("unchecked") @Override public T getEndpointInstance(Class endpointClass) throws InstantiationException { - WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); if (wac == null) { String message = "Failed to find the root WebApplicationContext. Was ContextLoaderListener not used?"; @@ -99,7 +97,6 @@ public class SpringConfigurator extends Configurator { } private String getBeanNameByType(WebApplicationContext wac, Class endpointClass) { - String wacId = wac.getId(); Map, String> beanNamesByType = cache.get(wacId); @@ -116,15 +113,14 @@ public class SpringConfigurator extends Configurator { else { beanNamesByType.put(endpointClass, NO_VALUE); if (names.length > 1) { - String message = "Found multiple @ServerEndpoint's of type " + endpointClass + ", names=" + names; - logger.error(message); - throw new IllegalStateException(message); + throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" + + endpointClass.getName() + "]: bean names " + names); } } } String beanName = beanNamesByType.get(endpointClass); - return NO_VALUE.equals(beanName) ? null : beanName; + return (NO_VALUE.equals(beanName) ? null : beanName); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptor.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptor.java index dc8e9da55ae..a2e1e8bc6b5 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptor.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2014 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. @@ -41,7 +41,7 @@ import org.springframework.web.socket.server.HandshakeInterceptor; */ public class HttpSessionHandshakeInterceptor implements HandshakeInterceptor { - private static Log logger = LogFactory.getLog(HttpSessionHandshakeInterceptor.class); + private static final Log logger = LogFactory.getLog(HttpSessionHandshakeInterceptor.class); private Collection attributeNames;