Skip to content

Commit a580d6d

Browse files
committed
Leniently ignore type mismatch for LoadTimeWeaverAware beans
Closes gh-33082
1 parent 66eddf9 commit a580d6d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.springframework.beans.BeansException;
3737
import org.springframework.beans.CachedIntrospectionResults;
3838
import org.springframework.beans.factory.BeanFactory;
39+
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
3940
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
4041
import org.springframework.beans.factory.ObjectProvider;
4142
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
@@ -949,7 +950,15 @@ protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory b
949950
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
950951
String[] weaverAwareNames = beanFactory.getBeanNamesForType(LoadTimeWeaverAware.class, false, false);
951952
for (String weaverAwareName : weaverAwareNames) {
952-
beanFactory.getBean(weaverAwareName, LoadTimeWeaverAware.class);
953+
try {
954+
beanFactory.getBean(weaverAwareName, LoadTimeWeaverAware.class);
955+
}
956+
catch (BeanNotOfRequiredTypeException ex) {
957+
if (logger.isDebugEnabled()) {
958+
logger.debug("Failed to initialize LoadTimeWeaverAware bean '" + weaverAwareName +
959+
"' due to unexpected type mismatch: " + ex.getMessage());
960+
}
961+
}
953962
}
954963

955964
// Stop using the temporary ClassLoader for type matching.

0 commit comments

Comments
 (0)