Never use 'this.' when accessing loggers
Ensure that `this.` is never used when accessing loggers. Issue: SPR-16968
This commit is contained in:
committed by
Juergen Hoeller
parent
0b53c1096a
commit
9de3689f63
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -74,8 +74,8 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
|
||||
* @param target the bean instance to destroy
|
||||
*/
|
||||
protected void destroyPrototypeInstance(Object target) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
|
||||
}
|
||||
if (getBeanFactory() instanceof ConfigurableBeanFactory) {
|
||||
((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -78,7 +78,7 @@ public class FailFastProblemReporter implements ProblemReporter {
|
||||
*/
|
||||
@Override
|
||||
public void warning(Problem problem) {
|
||||
this.logger.warn(problem, problem.getRootCause());
|
||||
logger.warn(problem, problem.getRootCause());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -440,8 +440,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
throw ex;
|
||||
}
|
||||
// Probably contains a placeholder: let's ignore it for type matching purposes.
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Ignoring bean class loading failure for bean '" + beanName + "'", ex);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignoring bean class loading failure for bean '" + beanName + "'", ex);
|
||||
}
|
||||
onSuppressedException(ex);
|
||||
}
|
||||
@@ -450,8 +450,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
throw ex;
|
||||
}
|
||||
// Probably contains a placeholder: let's ignore it for type matching purposes.
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Ignoring unresolvable metadata in bean definition '" + beanName + "'", ex);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignoring unresolvable metadata in bean definition '" + beanName + "'", ex);
|
||||
}
|
||||
onSuppressedException(ex);
|
||||
}
|
||||
@@ -521,8 +521,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
BeanCreationException bce = (BeanCreationException) rootCause;
|
||||
String exBeanName = bce.getBeanName();
|
||||
if (exBeanName != null && isCurrentlyInCreation(exBeanName)) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Ignoring match to currently created bean '" + exBeanName + "': " +
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignoring match to currently created bean '" + exBeanName + "': " +
|
||||
ex.getMessage());
|
||||
}
|
||||
onSuppressedException(ex);
|
||||
@@ -680,8 +680,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
|
||||
BeanDefinition bd = this.beanDefinitionMap.get(beanName);
|
||||
if (bd == null) {
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("No bean named '" + beanName + "' found in " + this);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("No bean named '" + beanName + "' found in " + this);
|
||||
}
|
||||
throw new NoSuchBeanDefinitionException(beanName);
|
||||
}
|
||||
@@ -725,8 +725,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
|
||||
@Override
|
||||
public void preInstantiateSingletons() throws BeansException {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Pre-instantiating singletons in " + this);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Pre-instantiating singletons in " + this);
|
||||
}
|
||||
|
||||
// Iterate over a copy to allow for init methods which in turn register new bean definitions.
|
||||
@@ -813,22 +813,22 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
else if (oldBeanDefinition.getRole() < beanDefinition.getRole()) {
|
||||
// e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTURE
|
||||
if (this.logger.isWarnEnabled()) {
|
||||
this.logger.warn("Overriding user-defined bean definition for bean '" + beanName +
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Overriding user-defined bean definition for bean '" + beanName +
|
||||
"' with a framework-generated bean definition: replacing [" +
|
||||
oldBeanDefinition + "] with [" + beanDefinition + "]");
|
||||
}
|
||||
}
|
||||
else if (!beanDefinition.equals(oldBeanDefinition)) {
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info("Overriding bean definition for bean '" + beanName +
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Overriding bean definition for bean '" + beanName +
|
||||
"' with a different definition: replacing [" + oldBeanDefinition +
|
||||
"] with [" + beanDefinition + "]");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Overriding bean definition for bean '" + beanName +
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Overriding bean definition for bean '" + beanName +
|
||||
"' with an equivalent definition: replacing [" + oldBeanDefinition +
|
||||
"] with [" + beanDefinition + "]");
|
||||
}
|
||||
@@ -871,8 +871,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
|
||||
BeanDefinition bd = this.beanDefinitionMap.remove(beanName);
|
||||
if (bd == null) {
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("No bean named '" + beanName + "' found in " + this);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("No bean named '" + beanName + "' found in " + this);
|
||||
}
|
||||
throw new NoSuchBeanDefinitionException(beanName);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -163,8 +163,8 @@ public class SimpleHttpServerFactoryBean implements FactoryBean<HttpServer>, Ini
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info("Starting HttpServer at address " + address);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Starting HttpServer at address " + address);
|
||||
}
|
||||
this.server.start();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||
throw new IllegalStateException("Cannot define alias '" + alias + "' for name '" +
|
||||
name + "': It is already registered for name '" + registeredName + "'.");
|
||||
}
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Overriding alias '" + alias + "' definition for registered name '" +
|
||||
registeredName + "' with new target name '" + name + "'");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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,7 +45,7 @@ public class CommonsLogWriter extends Writer {
|
||||
|
||||
public void write(char ch) {
|
||||
if (ch == '\n' && this.buffer.length() > 0) {
|
||||
this.logger.debug(this.buffer.toString());
|
||||
logger.debug(this.buffer.toString());
|
||||
this.buffer.setLength(0);
|
||||
}
|
||||
else {
|
||||
@@ -58,7 +58,7 @@ public class CommonsLogWriter extends Writer {
|
||||
for (int i = 0; i < length; i++) {
|
||||
char ch = buffer[offset + i];
|
||||
if (ch == '\n' && this.buffer.length() > 0) {
|
||||
this.logger.debug(this.buffer.toString());
|
||||
logger.debug(this.buffer.toString());
|
||||
this.buffer.setLength(0);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -603,7 +603,7 @@ public abstract class LogFactory {
|
||||
}
|
||||
|
||||
private void log(java.util.logging.Level level, Object message, Throwable exception) {
|
||||
if (logger.isLoggable(level)) {
|
||||
if (this.logger.isLoggable(level)) {
|
||||
LogRecord rec;
|
||||
if (message instanceof LogRecord) {
|
||||
rec = (LogRecord) message;
|
||||
|
||||
@@ -206,8 +206,8 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag
|
||||
Message<?> message = (timeout >= 0 ?
|
||||
((PollableChannel) channel).receive(timeout) : ((PollableChannel) channel).receive());
|
||||
|
||||
if (message == null && this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("Failed to receive message from channel '" + channel + "' within timeout: " + timeout);
|
||||
if (message == null && logger.isTraceEnabled()) {
|
||||
logger.trace("Failed to receive message from channel '" + channel + "' within timeout: " + timeout);
|
||||
}
|
||||
|
||||
return message;
|
||||
|
||||
@@ -82,7 +82,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
* container.
|
||||
*/
|
||||
public final void onDataAvailable() {
|
||||
this.logger.trace("I/O event onDataAvailable");
|
||||
logger.trace("I/O event onDataAvailable");
|
||||
this.state.get().onDataAvailable(this);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
* all data has been read.
|
||||
*/
|
||||
public void onAllDataRead() {
|
||||
this.logger.trace("I/O event onAllDataRead");
|
||||
logger.trace("I/O event onAllDataRead");
|
||||
this.state.get().onAllDataRead(this);
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> {
|
||||
* Sub-classes can call this to delegate container error notifications.
|
||||
*/
|
||||
public final void onError(Throwable ex) {
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("I/O event onError: " + ex);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("I/O event onError: " + ex);
|
||||
}
|
||||
this.state.get().onError(this, ex);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractListenerWriteFlushProcessor<T> implements Processo
|
||||
* container to cancel the upstream subscription.
|
||||
*/
|
||||
protected void cancel() {
|
||||
this.logger.trace("Received request to cancel");
|
||||
logger.trace("Received request to cancel");
|
||||
if (this.subscription != null) {
|
||||
this.subscription.cancel();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
* container.
|
||||
*/
|
||||
public final void onWritePossible() {
|
||||
this.logger.trace("Received onWritePossible");
|
||||
logger.trace("Received onWritePossible");
|
||||
this.state.get().onWritePossible(this);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
* container to cancel the upstream subscription.
|
||||
*/
|
||||
public void cancel() {
|
||||
this.logger.trace("Received request to cancel");
|
||||
logger.trace("Received request to cancel");
|
||||
if (this.subscription != null) {
|
||||
this.subscription.cancel();
|
||||
}
|
||||
|
||||
@@ -313,14 +313,14 @@ class ServletServerHttpResponse extends AbstractListenerServerHttpResponse {
|
||||
flush();
|
||||
}
|
||||
boolean ready = ServletServerHttpResponse.this.isWritePossible();
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("write: " + dataBuffer + " ready: " + ready);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("write: " + dataBuffer + " ready: " + ready);
|
||||
}
|
||||
int remaining = dataBuffer.readableByteCount();
|
||||
if (ready && remaining > 0) {
|
||||
int written = writeToOutputStream(dataBuffer);
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("written: " + written + " total: " + remaining);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("written: " + written + " total: " + remaining);
|
||||
}
|
||||
if (written == remaining) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -164,8 +164,8 @@ public class SimpleHttpServerJaxWsServiceExporter extends AbstractJaxWsServiceEx
|
||||
InetSocketAddress address = (this.hostname != null ?
|
||||
new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port));
|
||||
HttpServer server = HttpServer.create(address, this.backlog);
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info("Starting HttpServer at address " + address);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Starting HttpServer at address " + address);
|
||||
}
|
||||
server.start();
|
||||
this.server = server;
|
||||
|
||||
@@ -492,8 +492,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
@Override
|
||||
protected final void initServletBean() throws ServletException {
|
||||
getServletContext().log("Initializing Spring FrameworkServlet '" + getServletName() + "'");
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
this.logger.info("FrameworkServlet '" + getServletName() + "': initialization started");
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("FrameworkServlet '" + getServletName() + "': initialization started");
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
@@ -502,13 +502,13 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
initFrameworkServlet();
|
||||
}
|
||||
catch (ServletException | RuntimeException ex) {
|
||||
this.logger.error("Context initialization failed", ex);
|
||||
logger.error("Context initialization failed", ex);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
long elapsedTime = System.currentTimeMillis() - startTime;
|
||||
this.logger.info("FrameworkServlet '" + getServletName() + "': initialization completed in " +
|
||||
logger.info("FrameworkServlet '" + getServletName() + "': initialization completed in " +
|
||||
elapsedTime + " ms");
|
||||
}
|
||||
}
|
||||
@@ -567,8 +567,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
// Publish the context as a servlet context attribute.
|
||||
String attrName = getServletContextAttributeName();
|
||||
getServletContext().setAttribute(attrName, wac);
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("Published WebApplicationContext of servlet '" + getServletName() +
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Published WebApplicationContext of servlet '" + getServletName() +
|
||||
"' as ServletContext attribute [" + attrName + "]");
|
||||
}
|
||||
}
|
||||
@@ -617,8 +617,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
|
||||
*/
|
||||
protected WebApplicationContext createWebApplicationContext(@Nullable ApplicationContext parent) {
|
||||
Class<?> contextClass = getContextClass();
|
||||
if (this.logger.isTraceEnabled()) {
|
||||
this.logger.trace("Servlet '" + getServletName() +
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Servlet '" + getServletName() +
|
||||
"' will create custom WebApplicationContext context of class '" +
|
||||
contextClass.getName() + "'" + ", parent context [" + parent + "]");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user