Browse Source

jfinal 3.4

James 7 years ago
parent
commit
4f07fdff3a

+ 4 - 7
src/main/java/com/jfinal/captcha/CaptchaManager.java

@@ -38,17 +38,14 @@ public class CaptchaManager {
 	}
 	
 	public ICaptchaCache getCaptchaCache() {
-		ICaptchaCache cache = captchaCache;
-		if (cache == null) {
+		if (captchaCache == null) {
 			synchronized (this) {
-				cache = captchaCache;
-				if (cache == null) {
-					cache = new CaptchaCache();
-					captchaCache = cache;
+				if (captchaCache == null) {
+					captchaCache = new CaptchaCache();
 				}
 			}
 		}
-		return cache;
+		return captchaCache;
 	}
 }
 

+ 2 - 1
src/main/java/com/jfinal/plugin/ehcache/CacheInterceptor.java

@@ -41,8 +41,9 @@ public class CacheInterceptor implements Interceptor {
 	
 	private ReentrantLock getLock(String key) {
 		ReentrantLock lock = lockMap.get(key);
-		if (lock != null)
+		if (lock != null) {
 			return lock;
+		}
 		
 		lock = new ReentrantLock();
 		ReentrantLock previousLock = lockMap.putIfAbsent(key, lock);

+ 1 - 2
src/main/java/com/jfinal/plugin/ehcache/CacheKit.java

@@ -28,7 +28,6 @@ import net.sf.ehcache.Element;
 public class CacheKit {
 	
 	private static CacheManager cacheManager;
-	private static Object locker = new Object();
 	private static final Log log = Log.getLog(CacheKit.class);
 	
 	static void init(CacheManager cacheManager) {
@@ -42,7 +41,7 @@ public class CacheKit {
 	static Cache getOrAddCache(String cacheName) {
 		Cache cache = cacheManager.getCache(cacheName);
 		if (cache == null) {
-			synchronized(locker) {
+			synchronized(CacheKit.class) {
 				cache = cacheManager.getCache(cacheName);
 				if (cache == null) {
 					log.warn("Could not find cache config [" + cacheName + "], using default.");