-
Notifications
You must be signed in to change notification settings - Fork 38k
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
SimpleAliasRegistry registerAlias not atomic [SPR-16577] #21119
Comments
László Magyar commented Also I'm not sure the synchronization of the entire aliasMap is valid at all since inside the ConcurrentHashMap other lock obejects used. |
Juergen Hoeller commented Synchronization of the entire Since That said, |
László Magyar commented So if I get it right, synchronization on the entire map needed to get a consistent view of the map when iterate over it's elements. |
Juergen Hoeller commented Indeed, iteration needs to be guarded the same way (e.g. the existing synchronization in We usually fine-tune synchronization according to our common framework use cases. We could even enforce that registration and removal may only happen during single-threaded startup, then we wouldn't need any synchronization for aliases at all. While startup-time registration is the 99.9% case, we nevertheless allow for later registration and also for later overriding which is why we need some synchronization to begin with. We don't want to compromise performance for the common case though, hence the efficient direct lookup of individual entries on an underlying |
László Magyar opened SPR-16577 and commented
org.springframework.core.SimpleAliasRegistry class registerAlias method get - compute - put is not atomic.
It should be synchronized with this.aliasMap or java.util.concurrent.ConcurrentMap interface compute method should be used.
Affects: 4.3.14, 5.0.4
Issue Links:
Referenced from: commits 3dff1b3, 1b1a69a
Backported to: 4.3.15
The text was updated successfully, but these errors were encountered: