class ClosedState<R> extends CircuitState<R> {
  public ClosedState(CircuitBreakerImpl<R> breaker) {
    super(breaker, CircuitStats.create(breaker, capacityFor(breaker), true, null));
  }

  @Override
  public boolean tryAcquirePermit() {
    return true;
  }

  @Override
  public State getState() {
    return State.CLOSED;
  }

  @Override
  public synchronized void handleConfigChange() {
    stats = CircuitStats.create(breaker, capacityFor(breaker), true, stats);
  }

  /**
   * Checks to see if the executions and failure thresholds have been exceeded, opening the circuit if so.
   */
  @Override
  synchronized void checkThreshold(ExecutionContext<R> context) {<FILL_FUNCTION_BODY>}

  /**
   * Returns the capacity of the breaker in the closed state.
   */
  private static int capacityFor(CircuitBreaker<?> breaker) {
    if (breaker.getConfig().getFailureExecutionThreshold() != 0)
      return breaker.getConfig().getFailureExecutionThreshold();
    else
      return breaker.getConfig().getFailureThresholdingCapacity();
  }
}

    // Execution threshold can only be set for time based thresholding
    if (stats.getExecutionCount() >= config.getFailureExecutionThreshold()) {
      // Failure rate threshold can only be set for time based thresholding
      double failureRateThreshold = config.getFailureRateThreshold();
      if ((failureRateThreshold != 0 && stats.getFailureRate() >= failureRateThreshold) || (failureRateThreshold == 0
        && stats.getFailureCount() >= config.getFailureThreshold()))
        breaker.open(context);
    }
  
<methods>public java.time.Duration getRemainingDelay() ,public abstract dev.failsafe.CircuitBreaker.State getState() ,public dev.failsafe.internal.CircuitStats getStats() ,public void handleConfigChange() ,public synchronized void recordFailure(ExecutionContext<R>) ,public synchronized void recordSuccess() <variables>final non-sealed CircuitBreakerImpl<R> breaker,final non-sealed CircuitBreakerConfig<R> config,volatile dev.failsafe.internal.CircuitStats stats