SLING-7542 : Avoid shared session/resource resolver usage
SLING-7543 : Reduce reloading of bundles
diff --git a/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java b/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
index c1d64c0..ec242eb 100644
--- a/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
+++ b/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
@@ -131,7 +131,7 @@
* configuration property. This defaults to <code>Locale.ENGLISH</code> if
* the configuration property is not set.
*/
- private Locale defaultLocale = Locale.ENGLISH;
+ private volatile Locale defaultLocale = Locale.ENGLISH;
/**
* Map of cached resource bundles indexed by a key combined of the base name
diff --git a/src/main/java/org/apache/sling/i18n/impl/RootResourceBundle.java b/src/main/java/org/apache/sling/i18n/impl/RootResourceBundle.java
index 74cabfb..05e3a04 100644
--- a/src/main/java/org/apache/sling/i18n/impl/RootResourceBundle.java
+++ b/src/main/java/org/apache/sling/i18n/impl/RootResourceBundle.java
@@ -18,9 +18,9 @@
*/
package org.apache.sling.i18n.impl;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.Locale;
-import java.util.NoSuchElementException;
import java.util.ResourceBundle;
/**
@@ -38,18 +38,6 @@
*/
public class RootResourceBundle extends ResourceBundle {
- // The empty enumeration returned fomr getKeys()
- private final Enumeration<String> EMPTY = new Enumeration<String>() {
-
- public boolean hasMoreElements() {
- return false;
- }
-
- public String nextElement() {
- throw new NoSuchElementException();
- }
- };
-
// The pseudo Locale returned by getLocale()
private final Locale locale = new Locale("");
@@ -74,7 +62,6 @@
*/
@Override
public Enumeration<String> getKeys() {
- return EMPTY;
+ return Collections.emptyEnumeration();
}
-
}