Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1333

ThresholdCircuitBreaker checkState method contradicts javadoc/interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.5
    • None
    • lang.concurrent.*
    • None
    • java 8

    Description

      The ThresholdCircuitBreaker impl
      does not seem to comply with the interface. The checkState method should return whether the circuit is closed or not. However, it returns isOpen(). This contradicts what's given in the java doc example

      Example:

      ThresHoldCircuitBreaker breaker = new ThresholdCircuitBreaker(10L);

      breaker.incrementAndCheckState(9L) returns false meaning the circuit is closed and the requests should pass through. The checkState method should return true for below example in javadoc to be correct

      /**
      public void handleRequest(Request request) {
       *     long memoryUsed = estimateMemoryUsage(request);
       *     if (breaker.incrementAndCheckState(memoryUsed)) {
       *         // actually handle this request
       *     } else {
       *         // do something else, e.g. send an error code
       *     }
       * }
      */

      Attachments

        Activity

          People

            kinow Bruno P. Kinoshita
            vasusridhar vasumathi sridharan
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: