-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Improve SimpleAliasRegistryTests
#31353
Comments
@e-freni has volunteered to investigate this issue and potentially submit a PR to resolve it. |
@sbrannen I investigated the issue, and it concerns the hashmap. The length of the string affects the hash used for sorting in the hashmap. Consequently, 'x,' 'xx,' and 'testAlias4' push the key to be the first element tested, which allows the expected exception to be thrown. If you use 'alias4,' the calculated hash pushes the value to the end of the map, thus the method self-corrects the content of 'aliasMap' and prevents the exception from occurring. It can be fixed for 'alias4' if it's fixed, but for all variable string lengths, the test logic needs to be modified to cover those cases. Even though I would make them explicit and not with ALIAS4 constant. Let me know if this solution works for you, and I'll get to it. |
@e-freni thanks very much for investigating. If you're still up for it, we'd be happy to review a PR. Let us know please. |
Indeed, thanks for the detailed analysis, @e-freni! 👍
Aha... you're saying the iteration order over the map elements in So that means the main issue is not with the test but rather what I would consider a bug in Specifically, changing the names of aliases while maintaining the exact same set of logical alias pairs should not work sometimes and fail at other times. |
resolveAliasesWithComplexPlaceholderReplacement()
test is flakyresolveAliasesWithComplexPlaceholderReplacement()
test
resolveAliasesWithComplexPlaceholderReplacement()
testSimpleAliasRegistryTests
SimpleAliasRegistryTests
SimpleAliasRegistryTests
Prior to this commit, the alias resolution error message in SimpleAliasRegistry was misleading. When a resolution conflict is detected, the IllegalStateException thrown by resolveAliases(...) now states that the resolved alias is already registered for an `existingName` instead of the `registeredName`. See spring-projectsgh-31353 Closes spring-projectsgh-32025
Overview
This is a followup to #31348.
As stated in the TODO in
SimpleAliasRegistryTests
, theresolveAliasesWithComplexPlaceholderReplacement()
test is flaky.It passes as-is with
ALIAS4
set to"testAlias4"
, and it also passes for values such as"x"
,"xx"
,"xxx"
,"xxxx"
, and likely numerous other values.However, it fails for
"alias4"
,"xxxxx"
,"testAli"
, and likely numerous other values.The issue might be due to the use of a Mockito mock, but I do not currently have the time to investigate it further.
Deliverables
ALIAS4
to"alias4"
once the issue is resolved.The text was updated successfully, but these errors were encountered: