Skip to content

Commit

Permalink
优化熔断降级调用
Browse files Browse the repository at this point in the history
  • Loading branch information
chentianming11 committed Dec 31, 2021
1 parent 1fe156d commit 26900fb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter]
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.2.17</version>
<version>2.2.18</version>
</dependency>
```

Expand All @@ -67,7 +67,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter]
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.2.17</version>
<version>2.2.18</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.2.17</version>
<version>2.2.18</version>
</dependency>
```

Expand All @@ -53,7 +53,7 @@ This project depends on Retrofit-2.9.0, okhttp-3.14.9, and okio-1.17.5 versions.
<dependency>
<groupId>com.github.lianjiatech</groupId>
<artifactId>retrofit-spring-boot-starter</artifactId>
<version>2.2.17</version>
<version>2.2.18</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
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.2.17</version>
<version>2.2.18</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 @@ -35,10 +35,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
return method.invoke(source, args);
} catch (Throwable e) {
Throwable cause = e.getCause();
Object fallbackObject = getFallbackObject(cause);
// 熔断逻辑
if (cause instanceof RetrofitBlockException && degradeProperty.isEnable() && fallbackObject != null) {
return method.invoke(fallbackObject, args);
if (cause instanceof RetrofitBlockException && degradeProperty.isEnable()) {
Object fallbackObject = getFallbackObject(cause);
if (fallbackObject != null) {
return method.invoke(fallbackObject, args);
}
}
throw cause;
}
Expand Down

0 comments on commit 26900fb

Please sign in to comment.