struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [1/2] struts git commit: WW-4652 fixed a concurrency issue in addDefaultResourceBundle
Date Fri, 15 Jul 2016 08:49:28 GMT
Repository: struts
Updated Branches:
  refs/heads/master 7f5c8b620 -> cdbf697ad


WW-4652 fixed a concurrency issue in addDefaultResourceBundle


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/39ec62ac
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/39ec62ac
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/39ec62ac

Branch: refs/heads/master
Commit: 39ec62ac35a775687a7e0f81e80f77b2992068b3
Parents: d066891
Author: Przemek Bruski <pbruski@atlassian.com>
Authored: Fri Jul 1 16:36:36 2016 +0200
Committer: Przemek Bruski <pbruski@atlassian.com>
Committed: Fri Jul 1 16:36:36 2016 +0200

----------------------------------------------------------------------
 .../java/com/opensymphony/xwork2/util/LocalizedTextUtil.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/39ec62ac/core/src/main/java/com/opensymphony/xwork2/util/LocalizedTextUtil.java
----------------------------------------------------------------------
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 29fbd2a..ad3a713 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.text.MessageFormat;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 
 /**
@@ -141,14 +142,13 @@ public class LocalizedTextUtil {
      */
     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<String> bundles = classLoaderMap.get(ccl.hashCode());
             if (bundles == null) {
-                bundles = new ArrayList<String>();
-                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);


Mime
View raw message