Skip to content

Commit c53184c

Browse files
committed
Refined logging for advisors which are currently in creation
Issue: SPR-10430 (cherry picked from commit 62157fe)
1 parent f9f1069 commit c53184c

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -81,24 +81,32 @@ public List<Advisor> findAdvisorBeans() {
8181

8282
List<Advisor> advisors = new LinkedList<Advisor>();
8383
for (String name : advisorNames) {
84-
if (isEligibleBean(name) && !this.beanFactory.isCurrentlyInCreation(name)) {
85-
try {
86-
advisors.add(this.beanFactory.getBean(name, Advisor.class));
84+
if (isEligibleBean(name)) {
85+
if (this.beanFactory.isCurrentlyInCreation(name)) {
86+
if (logger.isDebugEnabled()) {
87+
logger.debug("Skipping currently created advisor '" + name + "'");
88+
}
8789
}
88-
catch (BeanCreationException ex) {
89-
Throwable rootCause = ex.getMostSpecificCause();
90-
if (rootCause instanceof BeanCurrentlyInCreationException) {
91-
BeanCreationException bce = (BeanCreationException) rootCause;
92-
if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) {
93-
if (logger.isDebugEnabled()) {
94-
logger.debug("Ignoring currently created advisor '" + name + "': " + ex.getMessage());
90+
else {
91+
try {
92+
advisors.add(this.beanFactory.getBean(name, Advisor.class));
93+
}
94+
catch (BeanCreationException ex) {
95+
Throwable rootCause = ex.getMostSpecificCause();
96+
if (rootCause instanceof BeanCurrentlyInCreationException) {
97+
BeanCreationException bce = (BeanCreationException) rootCause;
98+
if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) {
99+
if (logger.isDebugEnabled()) {
100+
logger.debug("Skipping advisor '" + name +
101+
"' with dependency on currently created bean: " + ex.getMessage());
102+
}
103+
// Ignore: indicates a reference back to the bean we're trying to advise.
104+
// We want to find advisors other than the currently created bean itself.
105+
continue;
95106
}
96-
// Ignore: indicates a reference back to the bean we're trying to advise.
97-
// We want to find advisors other than the currently created bean itself.
98-
continue;
99107
}
108+
throw ex;
100109
}
101-
throw ex;
102110
}
103111
}
104112
}

0 commit comments

Comments
 (0)