Skip to content

Conversation

@vincentstradiot
Copy link

@vincentstradiot vincentstradiot commented Dec 13, 2025

Hi, here is a Pull Request that:

  1. extends the existing SimpleAliasRegistryTests to cover the allowAliasOverriding functionality.
  2. updates the implementation to fix a corner case issue in the SimpleAliasRegistry (explanation below).

Old behaviour was:

  • register alias A -> B: ✅ OK
  • register alias A -> A: ✅ OK
    • ⚠️ But alias A -> B was gone, which is not the expected behaviour as alias A -> B was overridden.

To my opinion, this should only be allowed if allowAliasOverriding = true, in exactly the same way as the existing implementation would only allow registering alias [A -> C] if allowAliasOverriding = true.

New behaviour:

  • register alias A -> B: OK ✅
  • register alias A -> A:
    • ✅ OK if allowAliasOverriding = true
    • ❌ Otherwise throws exception

Behaviour covered the following test cases in this PR:

  • SimpleAliasRegistryTests.registerAliasWithSameName_GivenAliasOverridingAllowed_ThenReplacesExistingAlias
  • SimpleAliasRegistryTests.registerAliasWithSameName_GivenAliasOverridingNotAllowed_ThenThrowsException

Thank you for the review, and have a nice day.

1. Extend test cases with alias overriding functionality
2. Prevent overriding existing alias when registering an alias
with the same name

Signed-off-by: Vincent Stradiot <vincentstradiot@hotmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants