Explorar o código

Fix EH-CACHE after web context refresh (patch thanks to Travis Gregg).

Ben Alex %!s(int64=21) %!d(string=hai) anos
pai
achega
3648073461

+ 1 - 0
changelog.txt

@@ -19,6 +19,7 @@ Changes in version 0.6 (2004-xx-xx)
 * Fixed AbstractProcessingFilter to handle servlet spec container differences
 * Fixed AbstractIntegrationFilter to resolve a Weblogic compatibility issue
 * Fixed CasAuthenticationToken if proxy granting ticket callback not requested
+* Fixed EH-CACHE handling on web context refresh
 * Documentation improvements
 
 Changes in version 0.51 (2004-06-06)

+ 2 - 0
contributors.txt

@@ -26,6 +26,8 @@ contributions to the Acegi Security System for Spring project:
 
 * Scott Evans contributed improvements to the tablig package.
 
+* Travis Gregg contributed a fix to EH-CACHE usage after web context refresh.
+
 * Anyone else I've forgotten (please let me know so I can correct this).
 
 Plus of course all the people who use the project and provide feedback, bug

+ 8 - 7
core/src/main/java/org/acegisecurity/providers/cas/cache/EhCacheBasedTicketCache.java

@@ -95,15 +95,16 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache,
 
     public void afterPropertiesSet() throws Exception {
         if (CacheManager.getInstance().cacheExists(CACHE_NAME)) {
-            CacheManager.getInstance().removeCache(CACHE_NAME);
-        }
+            // don’t remove the cache
+        } else {
+            manager = CacheManager.create();
 
-        manager = CacheManager.create();
+            // Cache name, max memory, overflowToDisk, eternal, timeToLive, timeToIdle
+            cache = new Cache(CACHE_NAME, Integer.MAX_VALUE, false, false,
+                    minutesToIdle * 60, minutesToIdle * 60);
 
-        // Cache name, max memory, overflowToDisk, eternal, timeToLive, timeToIdle
-        cache = new Cache(CACHE_NAME, Integer.MAX_VALUE, false, false,
-                minutesToIdle * 60, minutesToIdle * 60);
-        manager.addCache(cache);
+            manager.addCache(cache);
+        }
     }
 
     public void destroy() throws Exception {

+ 8 - 7
core/src/main/java/org/acegisecurity/providers/dao/cache/EhCacheBasedUserCache.java

@@ -96,15 +96,16 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean,
 
     public void afterPropertiesSet() throws Exception {
         if (CacheManager.getInstance().cacheExists(CACHE_NAME)) {
-            CacheManager.getInstance().removeCache(CACHE_NAME);
-        }
+            // don’t remove the cache
+        } else {
+            manager = CacheManager.create();
 
-        manager = CacheManager.create();
+            // Cache name, max memory, overflowToDisk, eternal, timeToLive, timeToIdle
+            cache = new Cache(CACHE_NAME, Integer.MAX_VALUE, false, false,
+                    minutesToIdle * 60, minutesToIdle * 60);
 
-        // Cache name, max memory, overflowToDisk, eternal, timeToLive, timeToIdle
-        cache = new Cache(CACHE_NAME, Integer.MAX_VALUE, false, false,
-                minutesToIdle * 60, minutesToIdle * 60);
-        manager.addCache(cache);
+            manager.addCache(cache);
+        }
     }
 
     public void destroy() throws Exception {