mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Replace native method invoke with methodInvoke
This commit is contained in:
parent
d9982c6143
commit
fe55285e9c
@ -69,19 +69,9 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor
|
|||||||
sentinelRestTemplate.urlCleanerClass(),
|
sentinelRestTemplate.urlCleanerClass(),
|
||||||
sentinelRestTemplate.urlCleaner());
|
sentinelRestTemplate.urlCleaner());
|
||||||
if (urlCleanerMethod != null) {
|
if (urlCleanerMethod != null) {
|
||||||
try {
|
hostWithPathResource = (String) methodInvoke(urlCleanerMethod,
|
||||||
hostWithPathResource = (String) urlCleanerMethod.invoke(null,
|
hostWithPathResource);
|
||||||
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;
|
Entry hostEntry = null, hostWithPathEntry = null;
|
||||||
ClientHttpResponse response = null;
|
ClientHttpResponse response = null;
|
||||||
@ -123,7 +113,7 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor
|
|||||||
Method fallbackMethod = extractFallbackMethod(sentinelRestTemplate.fallback(),
|
Method fallbackMethod = extractFallbackMethod(sentinelRestTemplate.fallback(),
|
||||||
sentinelRestTemplate.fallbackClass());
|
sentinelRestTemplate.fallbackClass());
|
||||||
if (fallbackMethod != null) {
|
if (fallbackMethod != null) {
|
||||||
return methodInvoke(fallbackMethod, args);
|
return (ClientHttpResponse) methodInvoke(fallbackMethod, args);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new SentinelClientHttpResponse();
|
return new SentinelClientHttpResponse();
|
||||||
@ -134,16 +124,16 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor
|
|||||||
sentinelRestTemplate.blockHandler(),
|
sentinelRestTemplate.blockHandler(),
|
||||||
sentinelRestTemplate.blockHandlerClass());
|
sentinelRestTemplate.blockHandlerClass());
|
||||||
if (blockHandler != null) {
|
if (blockHandler != null) {
|
||||||
return methodInvoke(blockHandler, args);
|
return (ClientHttpResponse) methodInvoke(blockHandler, args);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new SentinelClientHttpResponse();
|
return new SentinelClientHttpResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientHttpResponse methodInvoke(Method method, Object... args) {
|
private Object methodInvoke(Method method, Object... args) {
|
||||||
try {
|
try {
|
||||||
return (ClientHttpResponse) method.invoke(null, args);
|
return method.invoke(null, args);
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException e) {
|
catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user