Closed spring-projects-issues closed 12 years ago
Juergen Hoeller commented
Fixed through a nested Map in MessageSourceSupport as suggested, without further optimizations since this is just affecting the default message fallback path anyway. Since default messages won't usually contain locale-specific formatting patterns, I doubt that this was an actual issue for many people before... Otherwise I couldn't explain why it remained unnoticed for so long!
Note that StaticMessageSource uses a compound String key with a stringified Locale included, so already effectively caches MessageFormats per Locale.
Juergen
Diogo Quintela opened SPR-9607 and commented
Hello,
org.springframework.context.support.MessageSourceSupport and org.springframework.context.support.StaticMessageSource
maintains a map to cache MessageFormat instances:
Map<String, MessageFormat> cachedMessageFormats = new HashMap<String, MessageFormat>();
The problem is that MessageFormat are created with locale information and the caches don't honor that.
I propose that it should be used instead.
Map<String, Map<Locale,MessageFormat>> cachedMessageFormats = new HashMap<String, Map<Locale,MessageFormat>>();
btw, since spring is now only Java5 why not replace all maps and synchronized blocks with ConcurrentMap and Lock's ?
Best regards Diogo Quintela
Affects: 3.1.2