-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getTypeForFactoryMethod
should catch NoClassDefFoundError
#33075
Comments
@HzjNeverStop Are you able to provide a sample application? I'm having a hard time following the example you're describing. Swallowing the exception is intentional since we assume that if the class isn't available there can be no beans of that type. |
I tried to reproduce this issue, which occurs when the method return type is a generic structure. |
Thanks, @HzjNeverStop. Something's definitely wrong here. The sample has: @AutoConfiguration(before = DemoBAutoConfiguration.class)
public class DemoAAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public DemoBean demoBean() {
return new DemoBean("from DemoAAutoConfiguration");
}
} and @AutoConfiguration
public class DemoBAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public DemoBean demoBean() {
return new DemoBean("from DemoBAutoConfiguration");
}
} Yet both
Stack trace of the exception that's swallowed:
|
I've tried patching Framework so that
I think this is exactly what we want. Unlike the exception above that's swallowed, the failure here precisely pinpoints the cause of the problem as it identifies We'll transfer this to the Framework team so that they can consider if they want to make a change here. |
getTypeForFactoryMethod
should catch NoClassDefFoundError
Environment: SpringBoot 3.2.6
In the following scenario, this behavior makes it difficult to locate the root cause of the problem:
For example, two Configuration classes A and B register two BeanDefinitions A and B with the same beanName, using @ConditionalOnMissingBean to ensure that only one BeanDefinition is effective.
When another Configuration class C registers a BeanDefinition, and this BeanDefinition uses a class that cannot be found, the following situation may occur:
As a result, the BeanDefinition B registered by Configuration class B is not skipped, causing springboot to throw a BeanDefinitionOverrideException. The root cause exception of the problem is swallowed in the OnBeanCondition#getBeanNamesForType method, making it difficult to locate the problem.
The swallowed stack trace:
The spring boot failure reason:
The text was updated successfully, but these errors were encountered: