cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1336666 - /cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
Date Thu, 10 May 2012 13:19:39 GMT
Author: coheigea
Date: Thu May 10 13:19:39 2012
New Revision: 1336666

URL: http://svn.apache.org/viewvc?rev=1336666&view=rev
Log:
[CXF-4294] - Fix for race condition in EhCache stores


Conflicts:

	rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java

Modified:
    cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java

Modified: cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java?rev=1336666&r1=1336665&r2=1336666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/cache/EHCacheReplayCache.java
Thu May 10 13:19:39 2012
@@ -25,6 +25,7 @@ import java.net.URL;
 
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 
 import org.apache.ws.security.cache.ReplayCache;
@@ -37,18 +38,15 @@ public class EHCacheReplayCache implemen
     
     public static final long DEFAULT_TTL = 3600L;
     public static final long MAX_TTL = DEFAULT_TTL * 12L;
-    private Cache cache;
+    private Ehcache cache;
     private CacheManager cacheManager;
     private long ttl = DEFAULT_TTL;
     
     public EHCacheReplayCache(String key, URL configFileURL) {
         cacheManager = EHCacheManagerHolder.getCacheManager(configFileURL);
-        if (!cacheManager.cacheExists(key)) {
-            cache = new Cache(key, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
-            cacheManager.addCache(cache);
-        } else {
-            cache = cacheManager.getCache(key);
-        }
+        
+        Ehcache newCache = new Cache(key, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL);
+        cache = cacheManager.addCacheIfAbsent(newCache);
     }
     
     /**



Mime
View raw message