You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/06/30 19:38:05 UTC

[1/3] git commit: [CXF-5802] Fix a condition introduced with the removeCache call where if two proxies are using the same cache, closing one (or having it GC'd) would cause the cache to become invalid.

Repository: cxf
Updated Branches:
  refs/heads/2.6.x-fixes faeb3e2e9 -> 1705271ca


[CXF-5802] Fix a condition introduced with the removeCache call where if two proxies are using the same cache, closing one (or having it GC'd) would cause the cache to become invalid.

Conflicts:
	rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
	systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/CachingTest.java

Conflicts:
	systests/ws-security/src/test/java/org/apache/cxf/systest/ws/cache/CachingTest.java


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6627bee4
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6627bee4
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6627bee4

Branch: refs/heads/2.6.x-fixes
Commit: 6627bee4db9ea9f1513937bb5e3da63202c9acee
Parents: faeb3e2
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Jun 30 12:29:00 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Mon Jun 30 13:29:03 2014 -0400

----------------------------------------------------------------------
 .../security/tokenstore/EHCacheTokenStore.java  | 42 ++++++++++++++++++--
 1 file changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6627bee4/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
index 7a2660f..1c51c0c 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
@@ -26,11 +26,13 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
+import net.sf.ehcache.Status;
 import net.sf.ehcache.config.CacheConfiguration;
 
 import org.apache.cxf.Bus;
@@ -44,7 +46,6 @@ import org.apache.cxf.ws.security.cache.EHCacheManagerHolder;
  * and the max TTL is 12 hours.
  */
 public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleListener {
-
     public static final long DEFAULT_TTL = 3600L;
     public static final long MAX_TTL = DEFAULT_TTL * 12L;
     
@@ -65,13 +66,34 @@ public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
         CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager)
             .overflowToDisk(false); //tokens not writable
         
-        Ehcache newCache = new Cache(cc);
+        Cache newCache = new RefCountCache(cc);
         cache = cacheManager.addCacheIfAbsent(newCache);
+        synchronized (cache) {
+            if (cache.getStatus() != Status.STATUS_ALIVE) {
+                cache = cacheManager.addCacheIfAbsent(newCache);
+            }
+            if (cache instanceof RefCountCache) {
+                ((RefCountCache)cache).incrementAndGet();
+            }
+        }
         
         // Set the TimeToLive value from the CacheConfiguration
         ttl = cc.getTimeToLiveSeconds();
     }
     
+    private static class RefCountCache extends Cache {
+        AtomicInteger count = new AtomicInteger();
+        public RefCountCache(CacheConfiguration cc) {
+            super(cc);
+        }
+        public int incrementAndGet() {
+            return count.incrementAndGet();
+        }
+        public int decrementAndGet() {
+            return count.decrementAndGet();
+        }
+    }
+    
     /**
      * Set a new (default) TTL value in seconds
      * @param newTtl a new (default) TTL value in seconds
@@ -115,13 +137,16 @@ public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
     }
     
     public void remove(String identifier) {
-        if (!StringUtils.isEmpty(identifier) && cache.isKeyInCache(identifier)) {
+        if (cache != null && !StringUtils.isEmpty(identifier) && cache.isKeyInCache(identifier)) {
             cache.remove(identifier);
         }
     }
 
     @SuppressWarnings("unchecked")
     public Collection<String> getTokenIdentifiers() {
+        if (cache == null) {
+            return null;
+        }
         return cache.getKeysWithExpiryCheck();
     }
     
@@ -139,6 +164,9 @@ public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
     }
     
     public SecurityToken getToken(String identifier) {
+        if (cache == null) {
+            return null;
+        }
         Element element = cache.get(identifier);
         if (element != null && !cache.isExpired(element)) {
             return (SecurityToken)element.getObjectValue();
@@ -180,7 +208,13 @@ public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
         if (cacheManager != null) {
             // this step is especially important for global shared cache manager
             if (cache != null) {
-                cacheManager.removeCache(cache.getName());
+                synchronized (cache) {
+                    if (cache instanceof RefCountCache) {
+                        if (((RefCountCache)cache).decrementAndGet() == 0) {
+                            cacheManager.removeCache(cache.getName());
+                        }
+                    }
+                }                
             }
             
             EHCacheManagerHolder.releaseCacheManger(cacheManager);


[2/3] git commit: Fix PMD issue

Posted by dk...@apache.org.
Fix PMD issue


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1f6dea5a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1f6dea5a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1f6dea5a

Branch: refs/heads/2.6.x-fixes
Commit: 1f6dea5acad04d421b9401088a5c4f727c67e871
Parents: 6627bee
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Jun 30 13:16:35 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Mon Jun 30 13:29:11 2014 -0400

----------------------------------------------------------------------
 .../apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java  | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1f6dea5a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
index 1c51c0c..2d8ac10 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/EHCacheTokenStore.java
@@ -209,10 +209,9 @@ public class EHCacheTokenStore implements TokenStore, Closeable, BusLifeCycleLis
             // this step is especially important for global shared cache manager
             if (cache != null) {
                 synchronized (cache) {
-                    if (cache instanceof RefCountCache) {
-                        if (((RefCountCache)cache).decrementAndGet() == 0) {
-                            cacheManager.removeCache(cache.getName());
-                        }
+                    if (cache instanceof RefCountCache
+                        && ((RefCountCache)cache).decrementAndGet() == 0) {
+                        cacheManager.removeCache(cache.getName());
                     }
                 }                
             }


[3/3] git commit: Recording .gitmergeinfo Changes

Posted by dk...@apache.org.
Recording .gitmergeinfo Changes


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1705271c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1705271c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1705271c

Branch: refs/heads/2.6.x-fixes
Commit: 1705271ca56be4f0e7dffc97c848664e2d80158c
Parents: 1f6dea5
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Jun 30 13:29:20 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Mon Jun 30 13:29:20 2014 -0400

----------------------------------------------------------------------
 .gitmergeinfo | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1705271c/.gitmergeinfo
----------------------------------------------------------------------
diff --git a/.gitmergeinfo b/.gitmergeinfo
index ee74f4f..f90ee47 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -48,6 +48,7 @@ B 094aab46fb968eaedbf25e72a009080c1f25d0b5
 B 096c114091aa0a3f4c33c19d77ed54fd2b5495b8
 B 09815dc32aaa55bd05eeb93d17b9afe9a396ed96
 B 09c7b2f670b62b3a4e4d8a700a8b44494bbdd662
+B 0a0b9deec75db92a58ed6743b91efc4d3870fea7
 B 0a9e2782d0f038e993b592f6f861d1ae9ecc3182
 B 0aaa864df1e906d467cfd616fb61be44857d6ad2
 B 0acc1a1ac6e61630c270e2be14241861e6621fce
@@ -292,6 +293,7 @@ B 3fdfad74ec15fab793782136bfa7f976b0960ef9
 B 4004fa9b03b2718b2653ee8da7e2e398f402f3d1
 B 400b61573a54481058b4acd6c8f2ad27923e5801
 B 400d82edb9682dc27f469c4e3b67ffdb78580c9e
+B 4031f53706247231e2b70244932fe1b6f5042444
 B 40414bc1caff4bfb058190705629a885b70a5356
 B 40603ee2465db23283e4d6a5a976c27ac73063be
 B 4068dbda66afc2a8dc9f070971823db130abe575
@@ -1245,6 +1247,7 @@ M 32d96f051dad120a70fd628f43753426eff6aa2f
 M 33471ad43675421745effe83cc43c9304d9117b8
 M 33e0f164e0c2221ad03ac24f1e4963751846d890
 M 34e11ae3abe5c95c27cfdb2c089cc9d48936edf7
+M 353771670f917714c8370a5bf45c298649622c69
 M 355c4d8b1ddad74fd209f31630e6e93e15168870
 M 35a4abda4b235632b75b40879f71d8a1d27f4fcc
 M 364fba1ae623619c537ecaca1b9de8013b1c0d68