Commits

Anonymous committed 914ee24

Now creates the cache from within the constructor. This prevents possible threading issues if the cache is not initialized during application startup.

  • Participants
  • Parent commits a690bec

Comments (0)

Files changed (1)

File src/core/java/com/opensymphony/oscache/general/GeneralCacheAdministrator.java

     public GeneralCacheAdministrator(Properties p) {
         super(p);
         log.info("Constructed GeneralCacheAdministrator()");
+        createCache();
     }
 
     /**
      * @return The cache
      */
     public Cache getCache() {
-        // Create the cache if it doesn't already exist
-        if (applicationCache == null) {
-            applicationCache = createCache();
-        }
-
         return applicationCache;
     }
 
 
     /**
      * Creates a cache in this admin
-     *
-     * @return The new cache
      */
-    private Cache createCache() {
+    private void createCache() {
         log.info("Creating new cache");
 
-        Cache newCache = new Cache(isMemoryCaching(), isUnlimitedDiskCache(), isBlocking(), algorithmClass, cacheCapacity);
+        applicationCache = new Cache(isMemoryCaching(), isUnlimitedDiskCache(), isBlocking(), algorithmClass, cacheCapacity);
 
-        configureStandardListeners(newCache);
-
-        return newCache;
+        configureStandardListeners(applicationCache);
     }
 }