Alias resolution in SimpleAliasRegistry
depends on hash codes of alias values
#32024
Labels
Milestone
SimpleAliasRegistry
depends on hash codes of alias values
#32024
Overview
As discussed in commit 5d309d5, alias resolution in
SimpleAliasRegistry.resolveAliases()
currently depends on the iteration order of map entries in thealiasMap
which is aConcurrentHashMap
.In other words, the order in which aliases are processed depends on their hash code values.
This results in different behavior for the same set of logical alias pairs if the names of some of the aliases are changed in such a way that their hash codes result in a different iteration order for the
aliasMap
.For example, given an existing, working application that relies on aliases and placeholder replacement for such aliases, simply changing the name of one of those aliases may result in failure to start the application.
Possible Solutions
Using a
LinkedHashMap
foraliasMap
andaliasCopy
ensures alias processing in the order in which aliases were registered.However, we currently use a
ConcurrentHashMap
foraliasMap
, so we would need to wrap that inCollections.synchronizedMap()
. That works, but we may not want to use a synchronizedLinkedHashMap
for thealiasMap
in general.Thus, another possibility proposed by @jhoeller is to track the names of registered aliases separately:
Related Issues
SimpleAliasRegistryTests
#31353The text was updated successfully, but these errors were encountered: