This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch 2.8.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/2.8.x by this push:
new 9a4dee953 [#4053] add cache for get RetryHandler bean (#4113)
9a4dee953 is described below
commit 9a4dee953ebc2f44e19849107c519c8f97950cf3
Author: Cheng YouLing <[email protected]>
AuthorDate: Wed Dec 13 09:50:02 2023 +0800
[#4053] add cache for get RetryHandler bean (#4113)
---
.../servicecomb/core/provider/consumer/InvokerUtils.java | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git
a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
index a952131ee..80776636a 100644
---
a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
+++
b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -77,6 +77,8 @@ public final class InvokerUtils {
private static volatile ScheduledExecutorService reactiveRetryPool;
+ private static RetryHandler retryHandler = null;
+
private static ScheduledExecutorService getOrCreateRetryPool() {
if (reactiveRetryPool == null) {
synchronized (LOCK) {
@@ -248,7 +250,9 @@ public final class InvokerUtils {
private static Response decorateSyncRetry(Invocation invocation,
GovernanceRequestExtractor request) {
try {
// governance implementations.
- RetryHandler retryHandler = BeanUtils.getBean(RetryHandler.class);
+ if (retryHandler == null) {
+ retryHandler = BeanUtils.getBean(RetryHandler.class);
+ }
Retry retry = retryHandler.getActuator(request);
if (retry != null) {
CheckedFunction0<Response> supplier = Retry
@@ -329,7 +333,9 @@ public final class InvokerUtils {
private static void decorateReactiveRetry(Invocation invocation,
DecorateCompletionStage<Response> dcs,
GovernanceRequestExtractor request) {
// governance implementations.
- RetryHandler retryHandler = BeanUtils.getBean(RetryHandler.class);
+ if (retryHandler == null) {
+ retryHandler = BeanUtils.getBean(RetryHandler.class);
+ }
Retry retry = retryHandler.getActuator(request);
if (retry != null) {
dcs.withRetry(retry, getOrCreateRetryPool());