Skip to content

SpringComponentRegistry - Handle missing Spring components adhering to the ComponentRegistry contract#4719

Merged
MateuszNaKodach merged 3 commits into
mainfrom
fix/spring-component-registry-not-found
Jul 8, 2026
Merged

SpringComponentRegistry - Handle missing Spring components adhering to the ComponentRegistry contract#4719
MateuszNaKodach merged 3 commits into
mainfrom
fix/spring-component-registry-not-found

Conversation

@MateuszNaKodach

Copy link
Copy Markdown
Contributor

Summary

  • SpringComponentRegistry#getComponent now catches NoSuchBeanDefinitionException for the Class-only and Class + name lookup paths and rethrows it as a ComponentNotFoundException, matching the ComponentRegistry contract instead of letting the Spring-specific exception leak through.
  • Preserves the original NoSuchBeanDefinitionException as the cause by adding a new ComponentNotFoundException(type/typeReference, name, cause) constructor, and fixes the TypeReference + name lookup path to include the requested name in the thrown exception instead of always passing null.

Test plan

  • SpringAxonApplicationTest extended with cases asserting ComponentNotFoundException (wrapping NoSuchBeanDefinitionException) is thrown for missing beans via getComponent(Class), getComponent(Class, name), and getComponent(TypeReference, name).

@MateuszNaKodach MateuszNaKodach requested a review from a team as a code owner July 7, 2026 15:00
@MateuszNaKodach MateuszNaKodach requested review from hatzlj, hjohn and zambrovski and removed request for a team July 7, 2026 15:00
@MateuszNaKodach MateuszNaKodach self-assigned this Jul 7, 2026
@MateuszNaKodach MateuszNaKodach added Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. Type: Bug Use to signal issues that describe a bug within the system. labels Jul 7, 2026
@MateuszNaKodach MateuszNaKodach added this to the Release 5.2.0 milestone Jul 7, 2026

@hatzlj hatzlj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One finding that i would change and a few minor things

Translate BeanNotOfRequiredTypeException into ComponentNotFoundException
for name-based lookups, and wrap the propagated NoUniqueBeanDefinitionException
so it no longer leaks a raw Spring exception, keeping all lookup paths
consistent with the ComponentRegistry contract. Also tag the newly added
constructors with @SInCE 5.2.0 and strengthen the name-preserving test
assertion so a regression to a null name would fail it.
@MateuszNaKodach MateuszNaKodach requested a review from hatzlj July 8, 2026 08:57

@hatzlj hatzlj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smcvb smcvb changed the title fix(extensions/spring): handle missing Spring components adhering to the ComponentRegistry contract Handle missing Spring components adhering to the ComponentRegistry contract Jul 8, 2026

@smcvb smcvb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, otherwise this looks good to me 👍

@MateuszNaKodach MateuszNaKodach requested a review from abuijze July 8, 2026 11:12
The NoSuchBeanDefinitionException and BeanNotOfRequiredTypeException catch
blocks translated to the same ComponentNotFoundException, so merge them into
a single multi-catch. Kept as an explicit two-type catch rather than the
shared BeansException supertype to avoid masking creation-time failures as
"component not found".
@MateuszNaKodach MateuszNaKodach changed the title Handle missing Spring components adhering to the ComponentRegistry contract SpringComponentRegistry - Handle missing Spring components adhering to the ComponentRegistry contract Jul 8, 2026
@MateuszNaKodach MateuszNaKodach merged commit 418d0e3 into main Jul 8, 2026
7 checks passed
@MateuszNaKodach MateuszNaKodach deleted the fix/spring-component-registry-not-found branch July 8, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. Type: Bug Use to signal issues that describe a bug within the system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants