Reputation: 10823
Is it safe to assume that all implementations of org.springframework.context.MessageSource interface are thread-safe after initialization?
I would expect that it's safe, but now I'm looking through Spring source code, and there's org.springframework.context.support.ReloadableResourceBundleMessageSource which reloads properties from time to time, and documentation doesn't say anything about being thread-safe...
EDIT: It seems that ReloadableResourceBundleMessageSource indeed is synchronized where it needs to be... however my original question remains.
Upvotes: 5
Views: 1907
Reputation: 309008
Just looked at the source code - no synchronized keywords anywhere, and writable state. No, it's not thread-safe.
With that said, what's the harm of a dirty-read from your app's point of view? A wrong label or message value? You probably don't have to worry about a missing value, because you'd have to redeploy the whole app if JSPs or classes were modified to use new messages. I think you're pretty safe here.
Upvotes: 3