From da9afaf84e367f0e195cc8f221778eb798595fb6 Mon Sep 17 00:00:00 2001 From: Luigi Fugaro Date: Wed, 30 Jul 2014 14:29:03 +0200 Subject: [PATCH] Updates as stated in PR#20 comments. --- .../xwork2/util/LocalizedTextUtil.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java b/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java index 953c6b2d4..4e9d4eb1d 100644 --- a/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java +++ b/xwork-core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java @@ -86,7 +86,7 @@ import java.util.concurrent.ConcurrentMap; */ public class LocalizedTextUtil { - private static final ConcurrentMap> classLoaderMap = new ConcurrentHashMap>(); + private static final ConcurrentMap> classLoaderMap = new ConcurrentHashMap>(); private static final Logger LOG = LoggerFactory.getLogger(LocalizedTextUtil.class); private static boolean reloadBundles = false; private static final ConcurrentMap bundlesMap = new ConcurrentHashMap(); @@ -106,9 +106,9 @@ public class LocalizedTextUtil { */ public static void clearDefaultResourceBundles() { ClassLoader ccl = getCurrentThreadContextClassLoader(); - List bundles = new ArrayList(); + Set bundles = new HashSet(); classLoaderMap.put(ccl.hashCode(), bundles); - bundles.add(0, XWORK_MESSAGES_BUNDLE); + bundles.add(XWORK_MESSAGES_BUNDLE); } /** @@ -132,14 +132,13 @@ public class LocalizedTextUtil { ClassLoader ccl = null; synchronized (classLoaderMap) { ccl = getCurrentThreadContextClassLoader(); - List bundles = classLoaderMap.get(ccl.hashCode()); + Set bundles = classLoaderMap.get(ccl.hashCode()); if (bundles == null) { - bundles = new ArrayList(); + bundles = new HashSet(); classLoaderMap.put(ccl.hashCode(), bundles); bundles.add(XWORK_MESSAGES_BUNDLE); } - bundles.remove(resourceBundleName); - bundles.add(0, resourceBundleName); + bundles.add(resourceBundleName); } if (LOG.isDebugEnabled()) { @@ -198,7 +197,7 @@ public class LocalizedTextUtil { * @return a localized message based on the specified key, or null if no localized message can be found for it */ public static String findDefaultText(String aTextName, Locale locale) { - List localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode()); + Set localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode()); for (String bundleName : localList) { ResourceBundle bundle = findResourceBundle(bundleName, locale);