diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java index cc532199a4f..96bb24e0d95 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java @@ -196,7 +196,6 @@ public class InitDestroyAnnotationBeanPostProcessor } private LifecycleMetadata buildLifecycleMetadata(final Class clazz) { - final boolean debug = logger.isDebugEnabled(); List initMethods = new ArrayList<>(); List destroyMethods = new ArrayList<>(); Class targetClass = clazz; @@ -209,14 +208,14 @@ public class InitDestroyAnnotationBeanPostProcessor if (this.initAnnotationType != null && method.isAnnotationPresent(this.initAnnotationType)) { LifecycleElement element = new LifecycleElement(method); currInitMethods.add(element); - if (debug) { - logger.debug("Found init method on class [" + clazz.getName() + "]: " + method); + if (logger.isTraceEnabled()) { + logger.trace("Found init method on class [" + clazz.getName() + "]: " + method); } } if (this.destroyAnnotationType != null && method.isAnnotationPresent(this.destroyAnnotationType)) { currDestroyMethods.add(new LifecycleElement(method)); - if (debug) { - logger.debug("Found destroy method on class [" + clazz.getName() + "]: " + method); + if (logger.isTraceEnabled()) { + logger.trace("Found destroy method on class [" + clazz.getName() + "]: " + method); } } }); @@ -276,8 +275,8 @@ public class InitDestroyAnnotationBeanPostProcessor if (!beanDefinition.isExternallyManagedInitMethod(methodIdentifier)) { beanDefinition.registerExternallyManagedInitMethod(methodIdentifier); checkedInitMethods.add(element); - if (logger.isDebugEnabled()) { - logger.debug("Registered init method on class [" + this.targetClass.getName() + "]: " + element); + if (logger.isTraceEnabled()) { + logger.trace("Registered init method on class [" + this.targetClass.getName() + "]: " + element); } } } @@ -287,8 +286,8 @@ public class InitDestroyAnnotationBeanPostProcessor if (!beanDefinition.isExternallyManagedDestroyMethod(methodIdentifier)) { beanDefinition.registerExternallyManagedDestroyMethod(methodIdentifier); checkedDestroyMethods.add(element); - if (logger.isDebugEnabled()) { - logger.debug("Registered destroy method on class [" + this.targetClass.getName() + "]: " + element); + if (logger.isTraceEnabled()) { + logger.trace("Registered destroy method on class [" + this.targetClass.getName() + "]: " + element); } } } @@ -301,10 +300,9 @@ public class InitDestroyAnnotationBeanPostProcessor Collection initMethodsToIterate = (checkedInitMethods != null ? checkedInitMethods : this.initMethods); if (!initMethodsToIterate.isEmpty()) { - boolean debug = logger.isDebugEnabled(); for (LifecycleElement element : initMethodsToIterate) { - if (debug) { - logger.debug("Invoking init method on bean '" + beanName + "': " + element.getMethod()); + if (logger.isTraceEnabled()) { + logger.trace("Invoking init method on bean '" + beanName + "': " + element.getMethod()); } element.invoke(target); } @@ -316,10 +314,9 @@ public class InitDestroyAnnotationBeanPostProcessor Collection destroyMethodsToUse = (checkedDestroyMethods != null ? checkedDestroyMethods : this.destroyMethods); if (!destroyMethodsToUse.isEmpty()) { - boolean debug = logger.isDebugEnabled(); for (LifecycleElement element : destroyMethodsToUse) { - if (debug) { - logger.debug("Invoking destroy method on bean '" + beanName + "': " + element.getMethod()); + if (logger.isTraceEnabled()) { + logger.trace("Invoking destroy method on bean '" + beanName + "': " + element.getMethod()); } element.invoke(target); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 22bfb117722..2ede680a312 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -1831,7 +1831,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac if (initMethod == null) { if (mbd.isEnforceInitMethod()) { - throw new BeanDefinitionValidationException("Couldn't find an init method named '" + + throw new BeanDefinitionValidationException("Could not find an init method named '" + initMethodName + "' on bean with name '" + beanName + "'"); } else {