diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-18 11:20:55 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-18 11:20:55 +0200 |
commit | 8a492ff267bccae3653331918f6fc3d3a11737dc (patch) | |
tree | 4d70b3f9f85d405f930318a58af94330c485c43c /sonar-core | |
parent | f82a857673501f6aa545406e9699b09edb8df650 (diff) | |
parent | 6b0cc08317c9e2901af91542c0177182eaaf8c38 (diff) | |
download | sonarqube-8a492ff267bccae3653331918f6fc3d3a11737dc.tar.gz sonarqube-8a492ff267bccae3653331918f6fc3d3a11737dc.zip |
Merge branch 'release-2.10'
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java index d1a98db5599..7ec38095fc9 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java @@ -45,7 +45,7 @@ public class I18nManager implements I18n, ServerExtension { private Map<String, ClassLoader> bundleToClassloaders; private Map<String, String> propertyToBundles; private ClassLoader languagePackClassLoader; - private Map<String,Map<Locale,String>> fileContentCache = Maps.newHashMap(); + private Map<String, Map<Locale, String>> fileContentCache = Maps.newHashMap(); public I18nManager(PluginRepository pluginRepository) { this.pluginRepository = pluginRepository; @@ -108,11 +108,11 @@ public class I18nManager implements I18n, ServerExtension { /** * Only the given locale is searched. Contrary to java.util.ResourceBundle, no strategy for locating the bundle is implemented in - * this method. + * this method. */ String messageFromFile(Locale locale, String filename, String relatedProperty, boolean keepInCache) { - Map<Locale,String> fileCache = fileContentCache.get(filename); - if (fileCache!=null && fileCache.containsKey(locale)) { + Map<Locale, String> fileCache = fileContentCache.get(filename); + if (fileCache != null && fileCache.containsKey(locale)) { return fileCache.get(locale); } @@ -129,19 +129,22 @@ public class I18nManager implements I18n, ServerExtension { if (input != null) { try { result = IOUtils.toString(input, "UTF-8"); - if (keepInCache && result!=null) { - if (fileCache==null) { - fileCache = Maps.newHashMap(); - fileContentCache.put(filename, fileCache); - } - fileCache.put(locale, result); - } + } catch (IOException e) { throw new SonarException("Fail to load file: " + filePath, e); } finally { IOUtils.closeQuietly(input); } } + + if (keepInCache) { + if (fileCache == null) { + fileCache = Maps.newHashMap(); + fileContentCache.put(filename, fileCache); + } + // put null value for negative caching. + fileCache.put(locale, result); + } } return result; } |