瀏覽代碼

优化cache创建逻辑

zhouhao 8 年之前
父節點
當前提交
c3ac262d24

+ 0 - 1
hsweb-system/hsweb-system-config/hsweb-system-config-bean/src/main/java/org/hswebframework/web/bean/config/ConfigBean.java

@@ -21,7 +21,6 @@ package org.hswebframework.web.bean.config;
 
 import org.hswebframework.web.commons.beans.GenericBean;
 
-import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 

+ 3 - 1
hsweb-system/hsweb-system-config/hsweb-system-config-bean/src/main/java/org/hswebframework/web/bean/config/SimpleConfigBean.java

@@ -91,7 +91,9 @@ public class SimpleConfigBean extends SimpleGenericBean<String> implements Confi
         if (cache == null) {
             synchronized (this) {
                 if (cache == null) {
-                    if (content == null || content.isEmpty()) cache = new HashMap<>();
+                    if (content == null || content.isEmpty()) {
+                        return null;
+                    }
                     cache = content.stream()
                             .collect(Collectors.toMap(ConfigContent::getKey, content -> content));
                 }