fix: fix npe when add circuitbreak module without feign.hystrix.enable=true (#1292)

pull/1295/head
andrew shan 1 year ago committed by GitHub
parent b6863b755d
commit ca0b8ba982
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,3 +10,4 @@
- [feat:upgrade jackson version.](https://github.com/Tencent/spring-cloud-tencent/pull/1257) - [feat:upgrade jackson version.](https://github.com/Tencent/spring-cloud-tencent/pull/1257)
- [fix:fix wrong report when using Zuul with instance not found exception.](https://github.com/Tencent/spring-cloud-tencent/pull/1283) - [fix:fix wrong report when using Zuul with instance not found exception.](https://github.com/Tencent/spring-cloud-tencent/pull/1283)
- [feat: merge lane router and lossless features from 2023](https://github.com/Tencent/spring-cloud-tencent/pull/1288) - [feat: merge lane router and lossless features from 2023](https://github.com/Tencent/spring-cloud-tencent/pull/1288)
- [fix: fix npe when add circuitbreak module without feign.hystrix.enable=true](https://github.com/Tencent/spring-cloud-tencent/pull/1292)

@ -113,10 +113,11 @@ public class PolarisFeignCircuitBreakerInvocationHandler implements InvocationHa
else if ("toString".equals(method.getName())) { else if ("toString".equals(method.getName())) {
return toString(); return toString();
} }
Supplier<Object> supplier = asSupplier(method, args);
if (circuitBreakerNameResolver != null) {
String circuitName = circuitBreakerNameResolver.resolveCircuitBreakerName(feignClientName, target, method); String circuitName = circuitBreakerNameResolver.resolveCircuitBreakerName(feignClientName, target, method);
CircuitBreaker circuitBreaker = factory.create(circuitName); CircuitBreaker circuitBreaker = factory.create(circuitName);
Supplier<Object> supplier = asSupplier(method, args);
Function<Throwable, Object> fallbackFunction; Function<Throwable, Object> fallbackFunction;
if (this.nullableFallbackFactory != null) { if (this.nullableFallbackFactory != null) {
fallbackFunction = throwable -> { fallbackFunction = throwable -> {
@ -145,6 +146,10 @@ public class PolarisFeignCircuitBreakerInvocationHandler implements InvocationHa
throw e.getCause(); throw e.getCause();
} }
} }
else {
return supplier.get();
}
}
private void unwrapAndRethrow(Exception exception) { private void unwrapAndRethrow(Exception exception) {
if (exception instanceof InvocationTargetException || exception instanceof NoFallbackAvailableException) { if (exception instanceof InvocationTargetException || exception instanceof NoFallbackAvailableException) {

Loading…
Cancel
Save