Bladeren bron

修改core-cache默认缓存策略;增加starter-api鉴权后的日志设置

Signed-off-by: luoshi <luoshi@qmth.com.cn>
luoshi 2 jaren geleden
bovenliggende
commit
f2822249ba

+ 2 - 2
core-cache/src/main/java/com/qmth/boot/core/cache/config/CacheAutoConfiguration.java

@@ -71,8 +71,8 @@ public class CacheAutoConfiguration {
     }
 
     private Caffeine<Object, Object> buildCaffeineConfig(Duration expireAfterWrite) {
-        //默认开启softValues,避免JVM撑爆
-        Caffeine<Object, Object> caffeine = Caffeine.newBuilder().softValues();
+        //暂不开启softValues
+        Caffeine<Object, Object> caffeine = Caffeine.newBuilder();
         //写入失效时长大于0时才启用
         if (expireAfterWrite.toMillis() > 0) {
             caffeine = caffeine.expireAfterWrite(expireAfterWrite);

+ 4 - 0
starter-api/src/main/java/com/qmth/boot/api/interceptor/impl/AuthorizationInterceptor.java

@@ -10,6 +10,7 @@ import com.qmth.boot.core.security.exception.AuthorizationException;
 import com.qmth.boot.core.security.model.AccessEntity;
 import com.qmth.boot.core.security.service.AuthorizationSupport;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.MDC;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -44,6 +45,9 @@ public class AuthorizationInterceptor extends AbstractInterceptor implements Log
                 // 默认取签名标识作为接口访问者标识
                 if (request.getAttribute(ATTRIBUTE_CALLER) == null) {
                     request.setAttribute(ATTRIBUTE_CALLER, entity.getLogName());
+                    MDC.put(MDC_CALLER, entity.getLogName());
+                } else {
+                    MDC.put(MDC_CALLER, "-");
                 }
             } catch (AuthorizationException ae) {
                 log.warn("Authorization faile: path={}, reason={}", request.getServletPath(), ae.getMessage());