Skip to content

Commit

Permalink
Leniently ignore type mismatch for LoadTimeWeaverAware beans
Browse files Browse the repository at this point in the history
Closes gh-33082
  • Loading branch information
jhoeller committed Jun 21, 2024
1 parent 66eddf9 commit a580d6d
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.CachedIntrospectionResults;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
Expand Down Expand Up @@ -949,7 +950,15 @@ protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory b
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
String[] weaverAwareNames = beanFactory.getBeanNamesForType(LoadTimeWeaverAware.class, false, false);
for (String weaverAwareName : weaverAwareNames) {
beanFactory.getBean(weaverAwareName, LoadTimeWeaverAware.class);
try {
beanFactory.getBean(weaverAwareName, LoadTimeWeaverAware.class);
}
catch (BeanNotOfRequiredTypeException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to initialize LoadTimeWeaverAware bean '" + weaverAwareName +
"' due to unexpected type mismatch: " + ex.getMessage());
}
}
}

// Stop using the temporary ClassLoader for type matching.
Expand Down

0 comments on commit a580d6d

Please sign in to comment.