From 952351d0f45d4559168a49ad650f12d8e1ab34bc Mon Sep 17 00:00:00 2001 From: chentianming Date: Thu, 17 Nov 2022 19:40:23 +0800 Subject: [PATCH] fix SentinelRetrofitDegrade --- README.md | 2 +- README_EN.md | 2 +- pom.xml | 2 +- .../config/RetrofitAutoConfiguration.java | 22 +++++++++---------- .../sentinel/SentinelRetrofitDegrade.java | 4 ++++ 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 02111fc..414dde5 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter] com.github.lianjiatech retrofit-spring-boot-starter - 2.3.9 + 2.3.10 ``` diff --git a/README_EN.md b/README_EN.md index 49ddbc3..fd68261 100644 --- a/README_EN.md +++ b/README_EN.md @@ -39,7 +39,7 @@ com.github.lianjiatech retrofit-spring-boot-starter - 2.3.9 + 2.3.10 ``` diff --git a/pom.xml b/pom.xml index 3cadaaa..aab6163 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.lianjiatech retrofit-spring-boot-starter - 2.3.9 + 2.3.10 retrofit-spring-boot-starter retrofit-spring-boot-starter diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.java index 6a230de..033730a 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitAutoConfiguration.java @@ -56,7 +56,7 @@ public static class RetrofitAdvanceConfiguration { @Bean @ConditionalOnMissingBean - public static PathMatchInterceptorBdfProcessor prototypeInterceptorBdfProcessor() { + public static PathMatchInterceptorBdfProcessor pathMatchInterceptorBdfProcessor() { return new PathMatchInterceptorBdfProcessor(); } } @@ -75,43 +75,43 @@ public SourceOkHttpClientRegistry sourceOkHttpClientRegistry( @Bean @ConditionalOnMissingBean - public ErrorDecoder.DefaultErrorDecoder defaultErrorDecoder() { + public ErrorDecoder.DefaultErrorDecoder retrofitDefaultErrorDecoder() { return new ErrorDecoder.DefaultErrorDecoder(); } @Bean @ConditionalOnMissingBean - public ErrorDecoderInterceptor errorDecoderInterceptor() { + public ErrorDecoderInterceptor retrofitErrorDecoderInterceptor() { return new ErrorDecoderInterceptor(); } @Bean @ConditionalOnMissingBean - public RetryInterceptor retryInterceptor() { + public RetryInterceptor retrofitRetryInterceptor() { return new RetryInterceptor(retrofitProperties.getGlobalRetry()); } @Bean @ConditionalOnMissingBean - public LoggingInterceptor loggingInterceptor() { + public LoggingInterceptor retrofitLoggingInterceptor() { return new LoggingInterceptor(retrofitProperties.getGlobalLog()); } @Bean @ConditionalOnMissingBean - public ServiceInstanceChooser serviceInstanceChooser() { + public ServiceInstanceChooser retrofitServiceInstanceChooser() { return new ServiceInstanceChooser.NoValidServiceInstanceChooser(); } @Bean @ConditionalOnMissingBean - public ServiceChooseInterceptor serviceChooseInterceptor(@Autowired ServiceInstanceChooser serviceInstanceChooser) { + public ServiceChooseInterceptor retrofitServiceChooseInterceptor(@Autowired ServiceInstanceChooser serviceInstanceChooser) { return new ServiceChooseInterceptor(serviceInstanceChooser); } @Bean @ConditionalOnMissingBean - public JacksonConverterFactory jacksonConverterFactory() { + public JacksonConverterFactory retrofitJacksonConverterFactory() { ObjectMapper objectMapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .setSerializationInclusion(JsonInclude.Include.NON_NULL); @@ -160,14 +160,14 @@ public Resilience4jConfiguration(RetrofitProperties properties) { @Bean @ConditionalOnMissingBean - public CircuitBreakerConfigRegistry circuitBreakerConfigRegistry( + public CircuitBreakerConfigRegistry retrofitCircuitBreakerConfigRegistry( @Autowired(required = false) List circuitBreakerConfigRegistrars) { return new CircuitBreakerConfigRegistry(circuitBreakerConfigRegistrars); } @Bean @ConditionalOnMissingBean - public RetrofitDegrade resilience4jRetrofitDegrade(CircuitBreakerConfigRegistry circuitBreakerConfigRegistry) { + public RetrofitDegrade retrofitResilience4jRetrofitDegrade(CircuitBreakerConfigRegistry circuitBreakerConfigRegistry) { return new Resilience4jRetrofitDegrade(CircuitBreakerRegistry.ofDefaults(), properties.getDegrade().getGlobalResilience4jDegrade(), circuitBreakerConfigRegistry); } @@ -186,7 +186,7 @@ public SentinelConfiguration(RetrofitProperties properties) { @Bean @ConditionalOnMissingBean - public RetrofitDegrade sentinelRetrofitDegrade() { + public RetrofitDegrade retrofitSentinelRetrofitDegrade() { return new SentinelRetrofitDegrade(properties.getDegrade().getGlobalSentinelDegrade()); } } diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelRetrofitDegrade.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelRetrofitDegrade.java index b89698c..f11edb4 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelRetrofitDegrade.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelRetrofitDegrade.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Objects; +import com.alibaba.csp.sentinel.Tracer; import org.springframework.core.annotation.AnnotatedElementUtils; import com.alibaba.csp.sentinel.Entry; @@ -104,6 +105,9 @@ public Response intercept(Chain chain) throws IOException { return chain.proceed(request); } catch (BlockException e) { throw new RetrofitBlockException(e); + } catch (Throwable t) { + Tracer.trace(t); + throw t; } finally { if (entry != null) { entry.exit();