修复微服务网关更新Bug

This commit is contained in:
zer0Black
2022-02-28 09:37:15 +08:00
parent 30ce69799d
commit 5cc1df6e5a
2 changed files with 5 additions and 3 deletions
@@ -21,6 +21,7 @@ import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils; import com.jero.common.util.oConvertUtils;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
@@ -156,7 +157,7 @@ public class AutoLogAspect {
// https://my.oschina.net/mengzhang6/blog/2395893 // https://my.oschina.net/mengzhang6/blog/2395893
Object[] arguments = new Object[paramsArray.length]; Object[] arguments = new Object[paramsArray.length];
for (int i = 0; i < paramsArray.length; i++) { for (int i = 0; i < paramsArray.length; i++) {
if (paramsArray[i] instanceof ServletRequest || paramsArray[i] instanceof ServletResponse || paramsArray[i] instanceof MultipartFile) { if (paramsArray[i] instanceof BindingResult || paramsArray[i] instanceof ServletRequest || paramsArray[i] instanceof ServletResponse || paramsArray[i] instanceof MultipartFile) {
//ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) //ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
//ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response //ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
continue; continue;
@@ -11,7 +11,8 @@ import com.alibaba.nacos.api.exception.NacosException;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import com.jero.boot.starter.redis.client.JeroRedisClient; import org.jero.common.constant.CacheConstant;
import org.jero.common.util.RedisUtil;
import com.jero.config.GatewayRoutersConfiguration; import com.jero.config.GatewayRoutersConfiguration;
import com.jero.config.RouterDataType; import com.jero.config.RouterDataType;
import org.springframework.cloud.gateway.event.RefreshRoutesEvent; import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
@@ -132,7 +133,7 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
if (configService == null) { if (configService == null) {
log.warn("initConfigService fail"); log.warn("initConfigService fail");
} }
Object configInfo = redisUtil.get("gateway_routes"); Object configInfo = redisUtil.get(CacheConstant.GATEWAY_ROUTES);
if (ObjectUtil.isNotEmpty(configInfo)) { if (ObjectUtil.isNotEmpty(configInfo)) {
log.info("获取网关当前配置:\r\n{}", configInfo); log.info("获取网关当前配置:\r\n{}", configInfo);
JSONArray array = JSON.parseArray(configInfo.toString()); JSONArray array = JSON.parseArray(configInfo.toString());