Improved code that manages the cache:
* removed unnecessary synchronization * protected the UtilCache object (static field) by making it private and final git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1343277 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -38,7 +38,7 @@ public class RegionManager {
|
||||
|
||||
public static final String module = RegionManager.class.getName();
|
||||
|
||||
protected static UtilCache<URL, Map<String, Region>> regionCache = UtilCache.createUtilCache("webapp.Regions.Config", 0, 0);
|
||||
private static final UtilCache<URL, Map<String, Region>> regionCache = UtilCache.createUtilCache("webapp.Regions.Config", 0, 0);
|
||||
|
||||
protected URL regionFile = null;
|
||||
|
||||
@@ -54,14 +54,8 @@ public class RegionManager {
|
||||
public Map<String, Region> getRegions() {
|
||||
Map<String, Region> regions = regionCache.get(regionFile);
|
||||
if (regions == null) {
|
||||
synchronized (this) {
|
||||
regions = regionCache.get(regionFile);
|
||||
if (regions == null) {
|
||||
if (Debug.verboseOn()) Debug.logVerbose("Regions not loaded for " + regionFile + ", loading now", module);
|
||||
regions = readRegionXml(regionFile);
|
||||
regionCache.put(regionFile, regions);
|
||||
}
|
||||
}
|
||||
if (Debug.verboseOn()) Debug.logVerbose("Regions not loaded for " + regionFile + ", loading now", module);
|
||||
regions = regionCache.putIfAbsentAndGet(regionFile, readRegionXml(regionFile));
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user