Use ConcurrentHashMap to cache the ResourceBundle instances
-----------------------------------------------------------

                 Key: SLING-2048
                 URL: https://issues.apache.org/jira/browse/SLING-2048
             Project: Sling
          Issue Type: Improvement
          Components: Extensions
    Affects Versions: I18n 2.0.4
            Reporter: Felix Meschberger
            Assignee: Felix Meschberger
             Fix For: I18n 2.0.6


The JcrResourceBundleProvider class internally caches the JcrResourceBundle 
instances created for later reuse. This is done in

    Map<String, Map<Locale, ResourceBundle>>

where regular HashMaps are used. Thus access must be properly synchronized to 
prevent concurrency issues.

This can be simplified (and made more performing) by using a single

   ConcurrentHashMap<Key, ResourceBundle>

where Key is a new Object encompassing the base name and the Locale provided to 
the ResourceBundleProvider.

This removes the requirement for explicit synchronization and makes the code 
much more readably (at the expense of introducing a key class where the 
hashCode() and equals() method have to be implemented).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to