[GenAI] Fix 11815: changing the catch handler in resolveBean so that for the non-EachBean case the original DisabledBeanException is rethrown #12148
+48
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: #11815
Bug description
When a bean is conditionally disabled by throwing a DisabledBeanException from a factory method, other beans that @require the disabled bean should also be considered unavailable.
Root Cause & Solutions
if a bean factory throws
DisabledBeanExceptionto indicate the bean should not be created, the current code catches that and wraps it into aDependencyInjectionException. That prevents higher-level resolution logic from recognizing the bean as "disabled" and leads to hard failures instead of optional/disabled behavior.The intended behavior is to propagate
DisabledBeanExceptionupward so callers can treat the bean as disabled (except for the EachBean parent-case where a newDisabledBeanExceptionis created to indicate the child disabled the parent).The minimal fix is to change the catch handler in resolveBean so that for the non-EachBean case the original
DisabledBeanExceptionis rethrown instead of being wrapped in aDependencyInjectionException.Steps to reproduce
Please use this command to execute the provided test: