diff --git a/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelProtectInterceptor.java b/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelProtectInterceptor.java index 2bfb39e3..18a895de 100644 --- a/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelProtectInterceptor.java +++ b/spring-cloud-alibaba-sentinel/src/main/java/org/springframework/cloud/alibaba/sentinel/custom/SentinelProtectInterceptor.java @@ -62,11 +62,17 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor String hostResource = uri.getScheme() + "://" + uri.getHost() + (uri.getPort() == -1 ? "" : ":" + uri.getPort()); String hostWithPathResource = hostResource + uri.getPath(); + boolean entryWithPath = true; + if (hostResource.equals(hostWithPathResource)) { + entryWithPath = false; + } Entry hostEntry = null, hostWithPathEntry = null; ClientHttpResponse response; try { - ContextUtil.enter(hostWithPathResource); - hostWithPathEntry = SphU.entry(hostWithPathResource); + ContextUtil.enter(hostResource); + if (entryWithPath) { + hostWithPathEntry = SphU.entry(hostWithPathResource); + } hostEntry = SphU.entry(hostResource); response = execution.execute(request, body); }