Commits

ltor...@81dbac14-341a-0410-aa85-cbcd92e6f43e  committed 3e74bc9

Issue number: CACHE-148 getInstance call not thread safe
Submitted by: Lars Torunski

  • Participants
  • Parent commits ec3f179

Comments (0)

Files changed (1)

File src/java/com/opensymphony/oscache/web/ServletCacheAdministrator.java

     * are loaded from the oscache.properties file in the classpath.
     * @return Returns the CacheAdministrator instance for this context
     */
-    public static ServletCacheAdministrator getInstance(ServletContext context, Properties p) {
-        ServletCacheAdministrator admin;
-        admin = (ServletCacheAdministrator) context.getAttribute(CACHE_ADMINISTRATOR_KEY);
+    public synchronized static ServletCacheAdministrator getInstance(ServletContext context, Properties p) {
+
+        ServletCacheAdministrator admin = (ServletCacheAdministrator) context.getAttribute(CACHE_ADMINISTRATOR_KEY);
 
         // First time we need to create the administrator and store it in the
         // servlet context