Browse Source

Never use 'this.' when accessing loggers

Ensure that `this.` is never used when accessing loggers.

Issue: SPR-16968
pull/1868/head
Phillip Webb 6 years ago committed by Juergen Hoeller
parent
commit
9de3689f63
  1. 6
      spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java
  2. 4
      spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java
  3. 36
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
  4. 6
      spring-context/src/main/java/org/springframework/remoting/support/SimpleHttpServerFactoryBean.java
  5. 2
      spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java
  6. 6
      spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java
  7. 4
      spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java
  8. 4
      spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java
  9. 8
      spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java
  10. 2
      spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java
  11. 4
      spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java
  12. 8
      spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java
  13. 6
      spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java
  14. 18
      spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java

6
spring-aop/src/main/java/org/springframework/aop/target/AbstractPrototypeBasedTargetSource.java

@ -1,5 +1,5 @@ @@ -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 @@ -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);

4
spring-beans/src/main/java/org/springframework/beans/factory/parsing/FailFastProblemReporter.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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());
}
}

36
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

@ -440,8 +440,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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);
}

6
spring-context/src/main/java/org/springframework/remoting/support/SimpleHttpServerFactoryBean.java

@ -1,5 +1,5 @@ @@ -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 @@ -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();
}

2
spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java

@ -69,7 +69,7 @@ public class SimpleAliasRegistry implements AliasRegistry { @@ -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 + "'");
}

6
spring-core/src/main/java/org/springframework/util/CommonsLogWriter.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 {

4
spring-jcl/src/main/java/org/apache/commons/logging/LogFactory.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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;

4
spring-messaging/src/main/java/org/springframework/messaging/core/GenericMessagingTemplate.java

@ -206,8 +206,8 @@ public class GenericMessagingTemplate extends AbstractDestinationResolvingMessag @@ -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;

8
spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerReadPublisher.java

@ -82,7 +82,7 @@ public abstract class AbstractListenerReadPublisher<T> implements Publisher<T> { @@ -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> { @@ -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> { @@ -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);
}

2
spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java

@ -103,7 +103,7 @@ public abstract class AbstractListenerWriteFlushProcessor<T> implements Processo @@ -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();
}

4
spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteProcessor.java

@ -100,7 +100,7 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T, @@ -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, @@ -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();
}

8
spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpResponse.java

@ -313,14 +313,14 @@ class ServletServerHttpResponse extends AbstractListenerServerHttpResponse { @@ -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()) {

6
spring-web/src/main/java/org/springframework/remoting/jaxws/SimpleHttpServerJaxWsServiceExporter.java

@ -1,5 +1,5 @@ @@ -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 @@ -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;

18
spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java

@ -492,8 +492,8 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic @@ -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 @@ -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 @@ -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 @@ -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 + "]");
}

Loading…
Cancel
Save