Consistent declaration of private static final logger variables

Issue: SPR-11905
(cherry picked from commit 18131bf)
This commit is contained in:
Juergen Hoeller 2014-07-01 12:09:29 +02:00
parent c32d5592c7
commit c16032b98a
13 changed files with 62 additions and 52 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 */ /** 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 */ /** Config used to configure this proxy */
private final AdvisedSupport advised; private final AdvisedSupport advised;

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { public abstract class ValidationUtils {
private static Log logger = LogFactory.getLog(ValidationUtils.class); private static final Log logger = LogFactory.getLog(ValidationUtils.class);
/** /**

View File

@ -54,7 +54,7 @@ import org.springframework.util.ClassUtils;
*/ */
public class LocalVariableTableParameterNameDiscoverer implements ParameterNameDiscoverer { 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 // marker object for classes that do not have any debug info
private static final Map<Member, String[]> NO_DEBUG_INFO_MAP = Collections.emptyMap(); private static final Map<Member, String[]> NO_DEBUG_INFO_MAP = Collections.emptyMap();

View File

@ -63,7 +63,7 @@ public class EmbeddedDatabaseFactory {
*/ */
public static final String DEFAULT_DATABASE_NAME = "testdb"; 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; private String databaseName = DEFAULT_DATABASE_NAME;

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { 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<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>(); private final List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
implements DeferredResultProcessingInterceptor { implements DeferredResultProcessingInterceptor {
private static Log logger = LogFactory.getLog(AsyncRequestInterceptor.class); private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class);
private final SessionFactory sessionFactory; private final SessionFactory sessionFactory;
@ -52,11 +52,13 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
private volatile boolean timeoutInProgress; private volatile boolean timeoutInProgress;
public AsyncRequestInterceptor(SessionFactory sessionFactory, SessionHolder sessionHolder) { public AsyncRequestInterceptor(SessionFactory sessionFactory, SessionHolder sessionHolder) {
this.sessionFactory = sessionFactory; this.sessionFactory = sessionFactory;
this.sessionHolder = sessionHolder; this.sessionHolder = sessionHolder;
} }
@Override @Override
public <T> void preProcess(NativeWebRequest request, Callable<T> task) { public <T> void preProcess(NativeWebRequest request, Callable<T> task) {
bindSession(); bindSession();
@ -90,11 +92,17 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
} }
} }
// Implementation of DeferredResultProcessingInterceptor methods // Implementation of DeferredResultProcessingInterceptor methods
public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) { } public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) {
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) { } }
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) { }
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) {
}
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) {
}
@Override @Override
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) { public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) {
@ -106,4 +114,5 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
public <T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) { public <T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) {
closeAfterTimeout(); closeAfterTimeout();
} }
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapter
implements DeferredResultProcessingInterceptor { implements DeferredResultProcessingInterceptor {
private static Log logger = LogFactory.getLog(AsyncRequestInterceptor.class); private static final Log logger = LogFactory.getLog(AsyncRequestInterceptor.class);
private final EntityManagerFactory emFactory; private final EntityManagerFactory emFactory;
@ -58,6 +58,7 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
this.emHolder = emHolder; this.emHolder = emHolder;
} }
@Override @Override
public <T> void preProcess(NativeWebRequest request, Callable<T> task) { public <T> void preProcess(NativeWebRequest request, Callable<T> task) {
bindSession(); bindSession();
@ -91,11 +92,17 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
} }
} }
// Implementation of DeferredResultProcessingInterceptor methods // Implementation of DeferredResultProcessingInterceptor methods
public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) { } public <T> void beforeConcurrentHandling(NativeWebRequest request, DeferredResult<T> deferredResult) {
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) { } }
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) { }
public <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferredResult) {
}
public <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult, Object result) {
}
@Override @Override
public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) { public <T> boolean handleTimeout(NativeWebRequest request, DeferredResult<T> deferredResult) {
@ -107,5 +114,5 @@ public class AsyncRequestInterceptor extends CallableProcessingInterceptorAdapte
public <T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) { public <T> void afterCompletion(NativeWebRequest request, DeferredResult<T> deferredResult) {
closeAfterTimeout(); closeAfterTimeout();
} }
}
}

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { class CallableInterceptorChain {
private static Log logger = LogFactory.getLog(CallableInterceptorChain.class); private static final Log logger = LogFactory.getLog(CallableInterceptorChain.class);
private final List<CallableProcessingInterceptor> interceptors; private final List<CallableProcessingInterceptor> interceptors;
@ -102,4 +102,5 @@ class CallableInterceptorChain {
} }
} }
} }
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { class DeferredResultInterceptorChain {
private static Log logger = LogFactory.getLog(DeferredResultInterceptorChain.class); private static final Log logger = LogFactory.getLog(DeferredResultInterceptorChain.class);
private final List<DeferredResultProcessingInterceptor> interceptors; private final List<DeferredResultProcessingInterceptor> interceptors;

View File

@ -16,12 +16,6 @@
package org.springframework.web.socket.handler; 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.io.IOException;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue; 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.Lock;
import java.util.concurrent.locks.ReentrantLock; 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 * 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 { 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<WebSocketMessage<?>> buffer = new LinkedBlockingQueue<WebSocketMessage<?>>(); private final Queue<WebSocketMessage<?>> buffer = new LinkedBlockingQueue<WebSocketMessage<?>>();
@ -61,7 +62,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
private volatile boolean limitExceeded; private volatile boolean limitExceeded;
private volatile boolean shutDownInProgress; private volatile boolean shutdownInProgress;
private final Lock flushLock = new ReentrantLock(); private final Lock flushLock = new ReentrantLock();
@ -87,7 +88,6 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
public void sendMessage(WebSocketMessage<?> message) throws IOException { public void sendMessage(WebSocketMessage<?> message) throws IOException {
if (isDisabled()) { if (isDisabled()) {
return; return;
} }
@ -110,7 +110,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
} }
private boolean isDisabled() { private boolean isDisabled() {
return (this.limitExceeded || this.shutDownInProgress); return (this.limitExceeded || this.shutdownInProgress);
} }
private boolean tryFlushMessageBuffer() throws IOException { private boolean tryFlushMessageBuffer() throws IOException {
@ -140,17 +140,13 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
if (!isDisabled() && this.closeLock.tryLock()) { if (!isDisabled() && this.closeLock.tryLock()) {
try { try {
if (getTimeSinceSendStarted() > this.sendTimeLimit) { if (getTimeSinceSendStarted() > this.sendTimeLimit) {
String errorMessage = "Message send time " + getTimeSinceSendStarted() + String errorMessage = "Message send time " + getTimeSinceSendStarted() +
" (ms) exceeded the allowed limit " + this.sendTimeLimit; " (ms) exceeded the allowed limit " + this.sendTimeLimit;
sessionLimitReached(errorMessage, CloseStatus.SESSION_NOT_RELIABLE); sessionLimitReached(errorMessage, CloseStatus.SESSION_NOT_RELIABLE);
} }
else if (this.bufferSize.get() > this.bufferSizeLimit) { else if (this.bufferSize.get() > this.bufferSizeLimit) {
String errorMessage = "The send buffer size " + this.bufferSize.get() + " bytes for " + String errorMessage = "The send buffer size " + this.bufferSize.get() + " bytes for " +
"session '" + getId() + " exceeded the allowed limit " + this.bufferSizeLimit; "session '" + getId() + " exceeded the allowed limit " + this.bufferSizeLimit;
sessionLimitReached(errorMessage, sessionLimitReached(errorMessage,
(getTimeSinceSendStarted() >= 10000 ? CloseStatus.SESSION_NOT_RELIABLE : null)); (getTimeSinceSendStarted() >= 10000 ? CloseStatus.SESSION_NOT_RELIABLE : null));
} }
@ -168,7 +164,8 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
@Override @Override
public void close(CloseStatus status) throws IOException { public void close(CloseStatus status) throws IOException {
this.shutDownInProgress = true; this.shutdownInProgress = true;
super.close(status); super.close(status);
} }
} }

View File

@ -57,7 +57,7 @@ import org.springframework.util.ReflectionUtils;
*/ */
public class ServerEndpointExporter implements InitializingBean, BeanPostProcessor, ApplicationContextAware { 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<Class<?>> annotatedEndpointClasses = new ArrayList<Class<?>>(); private final List<Class<?>> annotatedEndpointClasses = new ArrayList<Class<?>>();

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Rossen Stoyanchev
* @since 4.0 * @since 4.0
*
* @see ServerEndpointExporter * @see ServerEndpointExporter
*/ */
public class SpringConfigurator extends Configurator { 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, Map<Class<?>, String>> cache = private static final Map<String, Map<Class<?>, String>> cache =
new ConcurrentHashMap<String, Map<Class<?>, String>>(); new ConcurrentHashMap<String, Map<Class<?>, String>>();
private static final String NO_VALUE = ObjectUtils.identityToString(new Object());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException { public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
if (wac == null) { if (wac == null) {
String message = "Failed to find the root WebApplicationContext. Was ContextLoaderListener not used?"; 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) { private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
String wacId = wac.getId(); String wacId = wac.getId();
Map<Class<?>, String> beanNamesByType = cache.get(wacId); Map<Class<?>, String> beanNamesByType = cache.get(wacId);
@ -116,15 +113,14 @@ public class SpringConfigurator extends Configurator {
else { else {
beanNamesByType.put(endpointClass, NO_VALUE); beanNamesByType.put(endpointClass, NO_VALUE);
if (names.length > 1) { if (names.length > 1) {
String message = "Found multiple @ServerEndpoint's of type " + endpointClass + ", names=" + names; throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
logger.error(message); endpointClass.getName() + "]: bean names " + names);
throw new IllegalStateException(message);
} }
} }
} }
String beanName = beanNamesByType.get(endpointClass); String beanName = beanNamesByType.get(endpointClass);
return NO_VALUE.equals(beanName) ? null : beanName; return (NO_VALUE.equals(beanName) ? null : beanName);
} }
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { public class HttpSessionHandshakeInterceptor implements HandshakeInterceptor {
private static Log logger = LogFactory.getLog(HttpSessionHandshakeInterceptor.class); private static final Log logger = LogFactory.getLog(HttpSessionHandshakeInterceptor.class);
private Collection<String> attributeNames; private Collection<String> attributeNames;