This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new e9ebc2f set default value if the customer's config is invalid for
resilience4… (#2929)
e9ebc2f is described below
commit e9ebc2f53dc8703b791fe224ef5521b4e8608ad9
Author: Han Gao <[email protected]>
AuthorDate: Thu Feb 24 11:28:00 2022 +0800
set default value if the customer's config is invalid for resilience4…
(#2929)
* set default value if the customer's config is invalid for resilience4j
plugin
* remove junit4 to avoid test error
---
.../apache/shenyu/common/constant/Constants.java | 7 +++++-
.../dto/convert/rule/Resilience4JHandle.java | 28 ++++++++++++----------
shenyu-integrated-test/pom.xml | 7 ------
3 files changed, 22 insertions(+), 20 deletions(-)
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
index 1d4cc42..74a1c0d 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/constant/Constants.java
@@ -280,7 +280,12 @@ public interface Constants {
/**
* circuitBreaker circuitEnable.
*/
- int CIRCUIT_ENABLE = 0;
+ int CIRCUIT_DISABLE = 0;
+
+ /**
+ * circuitBreaker enable.
+ */
+ int CIRCUIT_ENABLE = 1;
/**
* circuitBreaker timeoutDuration.
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java
index 6674857..c15bcf5 100644
---
a/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java
+++
b/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/Resilience4JHandle.java
@@ -44,7 +44,7 @@ public class Resilience4JHandle {
/**
* circuitBreaker circuitEnable.
*/
- private int circuitEnable = Constants.CIRCUIT_ENABLE;
+ private int circuitEnable = Constants.CIRCUIT_DISABLE;
/**
* circuitBreaker timeoutDuration.
@@ -388,17 +388,21 @@ public class Resilience4JHandle {
* @param resilience4JHandle {@linkplain Resilience4JHandle}
*/
public void checkData(final Resilience4JHandle resilience4JHandle) {
-
resilience4JHandle.setTimeoutDurationRate(Math.max(resilience4JHandle.getTimeoutDurationRate(),
Constants.TIMEOUT_DURATION_RATE));
-
resilience4JHandle.setLimitRefreshPeriod(Math.max(resilience4JHandle.getLimitRefreshPeriod(),
Constants.LIMIT_REFRESH_PERIOD));
-
resilience4JHandle.setLimitForPeriod(Math.max(resilience4JHandle.getLimitForPeriod(),
Constants.LIMIT_FOR_PERIOD));
-
resilience4JHandle.setCircuitEnable(Math.max(resilience4JHandle.getCircuitEnable(),
Constants.CIRCUIT_ENABLE));
-
resilience4JHandle.setTimeoutDuration(Math.max(resilience4JHandle.getTimeoutDuration(),
Constants.TIMEOUT_DURATION));
+
resilience4JHandle.setTimeoutDurationRate(resilience4JHandle.getTimeoutDurationRate()
< 0 ? Constants.TIMEOUT_DURATION_RATE :
resilience4JHandle.getTimeoutDurationRate());
+
resilience4JHandle.setLimitRefreshPeriod(resilience4JHandle.getLimitRefreshPeriod()
< 0 ? Constants.LIMIT_REFRESH_PERIOD :
resilience4JHandle.getLimitRefreshPeriod());
+
resilience4JHandle.setLimitForPeriod(resilience4JHandle.getLimitForPeriod() < 0
? Constants.LIMIT_FOR_PERIOD : resilience4JHandle.getLimitForPeriod());
+
resilience4JHandle.setCircuitEnable(resilience4JHandle.getCircuitEnable() !=
Constants.CIRCUIT_ENABLE ? Constants.CIRCUIT_DISABLE :
Constants.CIRCUIT_ENABLE);
+
resilience4JHandle.setTimeoutDuration(resilience4JHandle.getTimeoutDuration() <
0 ? Constants.TIMEOUT_DURATION : resilience4JHandle.getTimeoutDuration());
resilience4JHandle.setFallbackUri(!"0".equals(resilience4JHandle.getFallbackUri())
? resilience4JHandle.getFallbackUri() : "");
-
resilience4JHandle.setSlidingWindowSize(Math.max(resilience4JHandle.getSlidingWindowSize(),
Constants.SLIDING_WINDOW_SIZE));
-
resilience4JHandle.setSlidingWindowType(Math.max(resilience4JHandle.getSlidingWindowType(),
Constants.SLIDING_WINDOW_TYPE));
-
resilience4JHandle.setMinimumNumberOfCalls(Math.max(resilience4JHandle.getMinimumNumberOfCalls(),
Constants.MINIMUM_NUMBER_OF_CALLS));
-
resilience4JHandle.setWaitIntervalFunctionInOpenState(Math.max(resilience4JHandle.getWaitIntervalFunctionInOpenState(),
Constants.WAIT_INTERVAL_FUNCTION_IN_OPEN_STATE));
-
resilience4JHandle.setPermittedNumberOfCallsInHalfOpenState(Math.max(resilience4JHandle.getPermittedNumberOfCallsInHalfOpenState(),
Constants.PERMITTED_NUMBER_OF_CALLS_IN_HALF_OPEN_STATE));
-
resilience4JHandle.setFailureRateThreshold(Math.max(resilience4JHandle.getFailureRateThreshold(),
Constants.FAILURE_RATE_THRESHOLD));
+
resilience4JHandle.setSlidingWindowSize(resilience4JHandle.getSlidingWindowSize()
< 0 ? Constants.SLIDING_WINDOW_SIZE :
resilience4JHandle.getSlidingWindowSize());
+
resilience4JHandle.setSlidingWindowType(resilience4JHandle.getSlidingWindowType()
< 0 ? Constants.SLIDING_WINDOW_TYPE :
resilience4JHandle.getSlidingWindowType());
+
resilience4JHandle.setMinimumNumberOfCalls(resilience4JHandle.getMinimumNumberOfCalls()
< 0 ? Constants.MINIMUM_NUMBER_OF_CALLS :
resilience4JHandle.getMinimumNumberOfCalls());
+
resilience4JHandle.setWaitIntervalFunctionInOpenState(resilience4JHandle.getWaitIntervalFunctionInOpenState()
< 0
+ ? Constants.WAIT_INTERVAL_FUNCTION_IN_OPEN_STATE :
resilience4JHandle.getWaitIntervalFunctionInOpenState());
+
resilience4JHandle.setPermittedNumberOfCallsInHalfOpenState(resilience4JHandle.getPermittedNumberOfCallsInHalfOpenState()
< 0
+ ? Constants.PERMITTED_NUMBER_OF_CALLS_IN_HALF_OPEN_STATE :
resilience4JHandle.getPermittedNumberOfCallsInHalfOpenState());
+ resilience4JHandle.setFailureRateThreshold(
+ resilience4JHandle.getFailureRateThreshold() < 0 ||
resilience4JHandle.getFailureRateThreshold() > 100
+ ? Constants.FAILURE_RATE_THRESHOLD :
resilience4JHandle.getFailureRateThreshold());
}
}
diff --git a/shenyu-integrated-test/pom.xml b/shenyu-integrated-test/pom.xml
index 38b585f..a1ec804 100644
--- a/shenyu-integrated-test/pom.xml
+++ b/shenyu-integrated-test/pom.xml
@@ -104,13 +104,6 @@
<artifactId>shenyu-spring-boot-starter-gateway</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<plugins>