提交 cfa0f6c8 编写于 作者: J Juergen Hoeller

Consistent final logger fields

上级 684d6ab5
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
......@@ -39,7 +39,7 @@ import org.springframework.aop.TargetSource;
public abstract class AbstractRefreshableTargetSource implements TargetSource, Refreshable {
/** Logger available to subclasses */
protected Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass());
protected Object targetObject;
......
......@@ -49,7 +49,6 @@ import org.springframework.web.reactive.result.method.HandlerMethodArgumentResol
import org.springframework.web.reactive.result.method.InvocableHandlerMethod;
import org.springframework.web.server.ServerWebExchange;
/**
* Supports the invocation of {@code @RequestMapping} methods.
*
......@@ -58,7 +57,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
public class RequestMappingHandlerAdapter implements HandlerAdapter, BeanFactoryAware, InitializingBean {
private static Log logger = LogFactory.getLog(RequestMappingHandlerAdapter.class);
private static final Log logger = LogFactory.getLog(RequestMappingHandlerAdapter.class);
private List<HandlerMethodArgumentResolver> customArgumentResolvers;
......
......@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
*/
public class ReactorHttpHandlerAdapter implements Function<HttpChannel, Mono<Void>> {
private static Log logger = LogFactory.getLog(ReactorHttpHandlerAdapter.class);
private static final Log logger = LogFactory.getLog(ReactorHttpHandlerAdapter.class);
private final HttpHandler delegate;
......
......@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
*/
public class RxNettyHttpHandlerAdapter implements RequestHandler<ByteBuf, ByteBuf> {
private static Log logger = LogFactory.getLog(RxNettyHttpHandlerAdapter.class);
private static final Log logger = LogFactory.getLog(RxNettyHttpHandlerAdapter.class);
private final HttpHandler delegate;
......
......@@ -48,7 +48,7 @@ public class ServletHttpHandlerAdapter extends HttpServlet {
private static final int DEFAULT_BUFFER_SIZE = 8192;
private static Log logger = LogFactory.getLog(ServletHttpHandlerAdapter.class);
private static final Log logger = LogFactory.getLog(ServletHttpHandlerAdapter.class);
private final HttpHandler handler;
......
......@@ -36,7 +36,7 @@ import org.springframework.util.Assert;
*/
public class UndertowHttpHandlerAdapter implements io.undertow.server.HttpHandler {
private static Log logger = LogFactory.getLog(UndertowHttpHandlerAdapter.class);
private static final Log logger = LogFactory.getLog(UndertowHttpHandlerAdapter.class);
private final HttpHandler delegate;
......
......@@ -42,7 +42,7 @@ import org.springframework.web.server.session.WebSessionManager;
*/
public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHandler {
private static Log logger = LogFactory.getLog(HttpWebHandlerAdapter.class);
private static final Log logger = LogFactory.getLog(HttpWebHandlerAdapter.class);
private WebSessionManager sessionManager = new DefaultWebSessionManager();
......
......@@ -41,8 +41,6 @@ import org.springframework.web.server.WebHandler;
*/
public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
private static Log logger = LogFactory.getLog(ExceptionHandlingWebHandler.class);
/**
* Log category to use on network IO exceptions after a client has gone away.
* <p>Servlet containers do not expose notifications when a client disconnects;
......@@ -56,30 +54,29 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
private static final String DISCONNECTED_CLIENT_LOG_CATEGORY =
ExceptionHandlingWebHandler.class.getName() + ".DisconnectedClient";
private static final Log disconnectedClientLogger = LogFactory.getLog(DISCONNECTED_CLIENT_LOG_CATEGORY);
private static final Set<String> DISCONNECTED_CLIENT_EXCEPTIONS;
static {
Set<String> set = new HashSet<>(3);
set.add("ClientAbortException"); // Tomcat
set.add("EOFException"); // Tomcat
set.add("EofException"); // Jetty
set.add("ClientAbortException"); // Tomcat
set.add("EOFException"); // Tomcat
set.add("EofException"); // Jetty
// java.io.IOException("Broken pipe") on WildFly (already covered)
DISCONNECTED_CLIENT_EXCEPTIONS = Collections.unmodifiableSet(set);
}
private static final Log logger = LogFactory.getLog(ExceptionHandlingWebHandler.class);
private static final Log disconnectedClientLogger = LogFactory.getLog(DISCONNECTED_CLIENT_LOG_CATEGORY);
private final List<WebExceptionHandler> exceptionHandlers;
public ExceptionHandlingWebHandler(WebHandler delegate, WebExceptionHandler... exceptionHandlers) {
super(delegate);
this.exceptionHandlers = initList(exceptionHandlers);
}
private static List<WebExceptionHandler> initList(WebExceptionHandler[] list) {
return (list != null ? Collections.unmodifiableList(Arrays.asList(list)):
Collections.emptyList());
this.exceptionHandlers = (exceptionHandlers != null ?
Collections.unmodifiableList(Arrays.asList(exceptionHandlers)): Collections.emptyList());
}
......@@ -115,6 +112,7 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator {
private void logException(Throwable ex) {
@SuppressWarnings("serial")
NestedCheckedException nestedException = new NestedCheckedException("", ex) {};
if ("Broken pipe".equalsIgnoreCase(nestedException.getMostSpecificCause().getMessage()) ||
DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName())) {
......
......@@ -42,7 +42,7 @@ import org.springframework.web.util.WebUtils;
*/
public class OriginHandshakeInterceptor implements HandshakeInterceptor {
protected Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass());
private final Set<String> allowedOrigins = new LinkedHashSet<>();
......
......@@ -55,7 +55,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
}
protected Log logger = LogFactory.getLog(getClass());
protected final Log logger = LogFactory.getLog(getClass());
private boolean xhrStreamingDisabled;
......@@ -71,11 +71,9 @@ public abstract class AbstractXhrTransport implements XhrTransport {
* An {@code XhrTransport} can support both the "xhr_streaming" and "xhr"
* SockJS server transports. From a client perspective there is no
* implementation difference.
*
* <p>Typically an {@code XhrTransport} is used as "XHR streaming" first and
* then, if that fails, as "XHR". In some cases however it may be helpful to
* suppress XHR streaming so that only XHR is attempted.
*
* <p>By default this property is set to {@code false} which means both
* "XHR streaming" and "XHR" apply.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册