From 39ec62ac35a775687a7e0f81e80f77b2992068b3 Mon Sep 17 00:00:00 2001 From: Przemek Bruski Date: Fri, 1 Jul 2016 16:36:36 +0200 Subject: [PATCH] WW-4652 fixed a concurrency issue in addDefaultResourceBundle --- .../com/opensymphony/xwork2/util/LocalizedTextUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java b/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java index 29fbd2a5e6..ad3a713dac 100644 --- a/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java +++ b/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java @@ -38,6 +38,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.CopyOnWriteArrayList; /** @@ -141,14 +142,13 @@ public static void setDevMode(boolean devMode) { */ public static void addDefaultResourceBundle(String resourceBundleName) { //make sure this doesn't get added more than once - ClassLoader ccl; + final ClassLoader ccl = getCurrentThreadContextClassLoader(); synchronized (XWORK_MESSAGES_BUNDLE) { - ccl = getCurrentThreadContextClassLoader(); List bundles = classLoaderMap.get(ccl.hashCode()); if (bundles == null) { - bundles = new ArrayList(); - classLoaderMap.put(ccl.hashCode(), bundles); + bundles = new CopyOnWriteArrayList<>(); bundles.add(XWORK_MESSAGES_BUNDLE); + classLoaderMap.put(ccl.hashCode(), bundles); } bundles.remove(resourceBundleName); bundles.add(0, resourceBundleName);