Skip to content

Commit

Permalink
WW-4652 fixed a concurrency issue in addDefaultResourceBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Przemek Bruski committed Jul 1, 2016
1 parent d066891 commit 39ec62a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;


/**
Expand Down Expand Up @@ -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<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);
Expand Down

0 comments on commit 39ec62a

Please sign in to comment.