From 62157fe38ff23b931e64a883b95739b07dcaef26 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 30 Oct 2013 00:29:21 +0100 Subject: [PATCH] Refined logging for advisors which are currently in creation Issue: SPR-10430 --- .../BeanFactoryAdvisorRetrievalHelper.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java index e417f92df0..c484520b89 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -81,24 +81,32 @@ public class BeanFactoryAdvisorRetrievalHelper { List advisors = new LinkedList(); for (String name : advisorNames) { - if (isEligibleBean(name) && !this.beanFactory.isCurrentlyInCreation(name)) { - try { - advisors.add(this.beanFactory.getBean(name, Advisor.class)); + if (isEligibleBean(name)) { + if (this.beanFactory.isCurrentlyInCreation(name)) { + if (logger.isDebugEnabled()) { + logger.debug("Skipping currently created advisor '" + name + "'"); + } } - catch (BeanCreationException ex) { - Throwable rootCause = ex.getMostSpecificCause(); - if (rootCause instanceof BeanCurrentlyInCreationException) { - BeanCreationException bce = (BeanCreationException) rootCause; - if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) { - if (logger.isDebugEnabled()) { - logger.debug("Ignoring currently created advisor '" + name + "': " + ex.getMessage()); + else { + try { + advisors.add(this.beanFactory.getBean(name, Advisor.class)); + } + catch (BeanCreationException ex) { + Throwable rootCause = ex.getMostSpecificCause(); + if (rootCause instanceof BeanCurrentlyInCreationException) { + BeanCreationException bce = (BeanCreationException) rootCause; + if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) { + if (logger.isDebugEnabled()) { + logger.debug("Skipping advisor '" + name + + "' with dependency on currently created bean: " + ex.getMessage()); + } + // Ignore: indicates a reference back to the bean we're trying to advise. + // We want to find advisors other than the currently created bean itself. + continue; } - // Ignore: indicates a reference back to the bean we're trying to advise. - // We want to find advisors other than the currently created bean itself. - continue; } + throw ex; } - throw ex; } } }