Author: doogie
Date: Wed Nov 25 20:47:51 2009
New Revision: 884262
URL:
http://svn.apache.org/viewvc?rev=884262&view=revLog:
Fix getOrCreateUtilCache, so that it doesn't always create new caches; mea culpa.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=884262&r1=884261&r2=884262&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Wed Nov 25 20:47:51 2009
@@ -617,9 +617,11 @@
@SuppressWarnings("unchecked")
public static <K, V> UtilCache<K, V> getOrCreateUtilCache(String name, int maxSize, int maxInMemory, long expireTime, boolean useSoftReference, boolean useFileSystemStore, String... names) {
+ UtilCache<K, V> existingCache = (UtilCache<K, V>) utilCacheTable.get(name);
+ if (existingCache != null) return existingCache;
String cacheName = name + getNextDefaultIndex(name);
UtilCache<K, V> newCache = new UtilCache<K, V>(cacheName, maxSize, maxInMemory, expireTime, useSoftReference, useFileSystemStore, name, names);
- UtilCache<K, V> oldCache = (UtilCache<K, V>) utilCacheTable.putIfAbsent(cacheName, newCache);
+ UtilCache<K, V> oldCache = (UtilCache<K, V>) utilCacheTable.putIfAbsent(name, newCache);
if (oldCache == null) {
return newCache;
} else {