Skip to content

Commit 68f925a

Browse files
committed
Add some comments to circuit breaker's closed and half open state thresholding
1 parent 14f16e2 commit 68f925a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/dev/failsafe/internal/ClosedState.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ public synchronized void handleConfigChange() {
4444
*/
4545
@Override
4646
synchronized void checkThreshold(ExecutionContext<R> context) {
47-
// Execution threshold will only be set for time based thresholding
47+
// Execution threshold can only be set for time based thresholding
4848
if (stats.getExecutionCount() >= config.getFailureExecutionThreshold()) {
49+
// Failure rate threshold can only be set for time based thresholding
4950
double failureRateThreshold = config.getFailureRateThreshold();
5051
if ((failureRateThreshold != 0 && stats.getFailureRate() >= failureRateThreshold) || (failureRateThreshold == 0
5152
&& stats.getFailureCount() >= config.getFailureThreshold()))

src/main/java/dev/failsafe/internal/HalfOpenState.java

+2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ synchronized void checkThreshold(ExecutionContext<R> context) {
6868
successesExceeded = stats.getSuccessCount() >= successThreshold;
6969
failuresExceeded = stats.getFailureCount() > successThresholdingCapacity - successThreshold;
7070
} else {
71+
// Failure rate threshold can only be set for time based thresholding
7172
int failureRateThreshold = config.getFailureRateThreshold();
7273
if (failureRateThreshold != 0) {
74+
// Execution threshold can only be set for time based thresholding
7375
boolean executionThresholdExceeded = stats.getExecutionCount() >= config.getFailureExecutionThreshold();
7476
failuresExceeded = executionThresholdExceeded && stats.getFailureRate() >= failureRateThreshold;
7577
successesExceeded = executionThresholdExceeded && stats.getSuccessRate() > 100 - failureRateThreshold;

0 commit comments

Comments
 (0)