Skip to content

Conversation

@Jarvx
Copy link

@Jarvx Jarvx commented Oct 21, 2025

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 DisabledBeanException to indicate the bean should not be created, the current code catches that and wraps it into a DependencyInjectionException. 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 DisabledBeanException upward so callers can treat the bean as disabled (except for the EachBean parent-case where a new DisabledBeanException is 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 DisabledBeanException is rethrown instead of being wrapped in a DependencyInjectionException.

Steps to reproduce

Please use this command to execute the provided test:

./gradlew :test-suite-kotlin-ksp:test

@Jarvx Jarvx changed the title Fix 11815: changing the catch handler in resolveBean so that for the non-EachBean case the original DisabledBeanException is rethrown [GEnAI] Fix 11815: changing the catch handler in resolveBean so that for the non-EachBean case the original DisabledBeanException is rethrown Oct 24, 2025
@Jarvx Jarvx changed the title [GEnAI] Fix 11815: changing the catch handler in resolveBean so that for the non-EachBean case the original DisabledBeanException is rethrown [GenAI] Fix 11815: changing the catch handler in resolveBean so that for the non-EachBean case the original DisabledBeanException is rethrown Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant