From b4d5dc1c8f6eda454ea4606a2905dee49bcbaf2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= Date: Fri, 19 Apr 2019 14:44:30 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20hutool=20=E8=9B=87?= =?UTF-8?q?=E7=9A=AE=20=E5=BA=8F=E5=88=97=E5=8C=96null=20=E4=B8=BA?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=20JSONNULL=20=E5=AF=B9=E8=B1=A1=20=E9=80=A0?= =?UTF-8?q?=E6=88=90=E8=BE=93=E5=87=BAJSON=20=E4=B8=8D=E8=83=BD=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud/openfeign/PigxFeignFallback.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pigx-common/pigx-common-security/src/main/java/org/springframework/cloud/openfeign/PigxFeignFallback.java b/pigx-common/pigx-common-security/src/main/java/org/springframework/cloud/openfeign/PigxFeignFallback.java index 18a39a96c..76f52c408 100644 --- a/pigx-common/pigx-common-security/src/main/java/org/springframework/cloud/openfeign/PigxFeignFallback.java +++ b/pigx-common/pigx-common-security/src/main/java/org/springframework/cloud/openfeign/PigxFeignFallback.java @@ -18,10 +18,12 @@ package org.springframework.cloud.openfeign; import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; +import com.fasterxml.jackson.databind.ObjectMapper; import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.core.util.SpringContextHolder; import feign.FeignException; import lombok.AllArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.cglib.proxy.MethodInterceptor; import org.springframework.cglib.proxy.MethodProxy; @@ -45,6 +47,7 @@ public class PigxFeignFallback implements MethodInterceptor { @Nullable @Override + @SneakyThrows public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) { Class returnType = method.getReturnType(); if (R.class != returnType) { @@ -57,7 +60,8 @@ public class PigxFeignFallback implements MethodInterceptor { String str = StrUtil.str(content, StandardCharsets.UTF_8); log.error("PigxFeignFallback:[{}.{}] serviceId:[{}] message:[{}]", targetType.getName(), method.getName(), targetName, str); - return JSONUtil.toBean(str, R.class); + ObjectMapper objectMapper = SpringContextHolder.getBean(ObjectMapper.class); + return objectMapper.readValue(str, R.class); } @Override