Consistent final logger fields

This commit is contained in:
Juergen Hoeller
2016-10-04 23:00:36 +02:00
parent 684d6ab553
commit cfa0f6c84b
10 changed files with 21 additions and 26 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();

View File

@@ -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())) {