From 44f073cdb4f498a62165f8cf843a761c4b20b8d0 Mon Sep 17 00:00:00 2001 From: Rivers-Shall Date: Mon, 19 Aug 2019 15:59:45 +0800 Subject: [PATCH] Use public static method `UrlCleaner` in `UrlCleanerClass` to clean `hostWithPathResource` --- .../custom/SentinelProtectInterceptor.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spring-cloud-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelProtectInterceptor.java b/spring-cloud-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelProtectInterceptor.java index 4594caefb..fd91016eb 100644 --- a/spring-cloud-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelProtectInterceptor.java +++ b/spring-cloud-alibaba-sentinel/src/main/java/com/alibaba/cloud/sentinel/custom/SentinelProtectInterceptor.java @@ -65,6 +65,24 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor if (hostResource.equals(hostWithPathResource)) { entryWithPath = false; } + Method urlCleanerMethod = BlockClassRegistry.lookupUrlCleaner( + sentinelRestTemplate.urlCleanerClass(), + sentinelRestTemplate.urlCleaner()); + if (urlCleanerMethod != null) { + try { + hostWithPathResource = (String) urlCleanerMethod.invoke(null, + hostWithPathResource); + } + catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + System.out.println("hostWithPathResource: " + hostWithPathResource); + System.out.println("entryWithPath: " + entryWithPath); + Entry hostEntry = null, hostWithPathEntry = null; ClientHttpResponse response = null; try {