Skip to content

CircuitBreaker stays in OPEN even after DELAY time #378

Open
@epischel

Description

@epischel

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions