Skip to content

Commit

Permalink
fix SentinelRetrofitDegrade
Browse files Browse the repository at this point in the history
  • Loading branch information
chentianming11 committed Nov 17, 2022
1 parent 80b5e01 commit 952351d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter]
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.3.9</version>
<version>2.3.10</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.3.9</version>
<version>2.3.10</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.3.9</version>
<version>2.3.10</version>

<name>retrofit-spring-boot-starter</name>
<description>retrofit-spring-boot-starter</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static class RetrofitAdvanceConfiguration {

@Bean
@ConditionalOnMissingBean
public static PathMatchInterceptorBdfProcessor prototypeInterceptorBdfProcessor() {
public static PathMatchInterceptorBdfProcessor pathMatchInterceptorBdfProcessor() {
return new PathMatchInterceptorBdfProcessor();
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -160,14 +160,14 @@ public Resilience4jConfiguration(RetrofitProperties properties) {

@Bean
@ConditionalOnMissingBean
public CircuitBreakerConfigRegistry circuitBreakerConfigRegistry(
public CircuitBreakerConfigRegistry retrofitCircuitBreakerConfigRegistry(
@Autowired(required = false) List<CircuitBreakerConfigRegistrar> 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);
}
Expand All @@ -186,7 +186,7 @@ public SentinelConfiguration(RetrofitProperties properties) {

@Bean
@ConditionalOnMissingBean
public RetrofitDegrade sentinelRetrofitDegrade() {
public RetrofitDegrade retrofitSentinelRetrofitDegrade() {
return new SentinelRetrofitDegrade(properties.getDegrade().getGlobalSentinelDegrade());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 952351d

Please sign in to comment.