diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/loadbalancer/BaseServerChooser.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/loadbalancer/BaseServerChooser.java index a452476f..e92a2fb2 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/loadbalancer/BaseServerChooser.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/loadbalancer/BaseServerChooser.java @@ -53,7 +53,7 @@ public abstract class BaseServerChooser extends ZoneAvoidanceRule { ILoadBalancer lb = getLoadBalancer(); // 获取服务实例列表 List servers = lb.getReachableServers(); - HttpServletRequest request = RequestContext.getCurrentContext().getRequest(); + RequestContext currentContext = RequestContext.getCurrentContext(); // 存放预发服务器 List preServers = new ArrayList<>(4); // 存放灰度发布服务器 @@ -77,11 +77,11 @@ public abstract class BaseServerChooser extends ZoneAvoidanceRule { return super.choose(key); } // 如果是从预发布域名访问过来,则认为是预发布请求 - if (this.isRequestFromPreDomain(request)) { + if (this.isRequestFromPreDomain(currentContext.getRequest())) { return doChoose(preServers, key); } // 如果是灰度请求 - if (this.isRequestGrayServer(RequestContext.getCurrentContext())) { + if (this.isRequestGrayServer(currentContext)) { return doChoose(grayServers, key); }