Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CircuitBreaker stays in OPEN even after DELAY time #378

Open
epischel opened this issue Mar 1, 2024 · 1 comment
Open

CircuitBreaker stays in OPEN even after DELAY time #378

epischel opened this issue Mar 1, 2024 · 1 comment

Comments

@epischel
Copy link

epischel commented Mar 1, 2024

I configure a CircuitBreaker with a delay. I expect to transition from OPEN to HALFOPEN after delay-time given that nothing gets recorded. It does not happen.
Code to observe this behaviour:

  public static void main(String[] args) throws InterruptedException {
    final CircuitBreaker<Object> circuitBreaker =
        CircuitBreaker.builder()
            .withFailureThreshold(3)
            .withSuccessThreshold(3)
            .withDelay(Duration.ofMinutes(2))
            .build();
    // bring to OPEN state
    circuitBreaker.recordFailure();
    circuitBreaker.recordFailure();
    circuitBreaker.recordFailure();
    circuitBreaker.recordFailure();
    // print state every 10 seconds
    for (int i = 0; i < 4 * 6; i++) {
      System.out.println(LocalDateTime.now());
      System.out.println(circuitBreaker.getState());
      System.out.println(circuitBreaker.getRemainingDelay());
      Thread.sleep(10_000L);
    }
  }

Is this intended behaviour?

@williamroberts
Copy link

I would also appreciate an understanding of why the CircuitBreaker never appears to change state in this scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants