You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Atul Agrawal (JIRA)" <ji...@apache.org> on 2017/06/15 10:41:00 UTC

[jira] [Commented] (LANG-1333) ThresholdCircuitBreaker checkState method contradicts javadoc/interface

    [ https://issues.apache.org/jira/browse/LANG-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16050308#comment-16050308 ] 

Atul Agrawal commented on LANG-1333:
------------------------------------

Your observation looks correct to me. An easy way is to fix documentation but it wouldn't be natural in terms of code readability.

> ThresholdCircuitBreaker checkState method contradicts javadoc/interface
> -----------------------------------------------------------------------
>
>                 Key: LANG-1333
>                 URL: https://issues.apache.org/jira/browse/LANG-1333
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.concurrent.*
>    Affects Versions: 3.5
>         Environment: java 8
>            Reporter: vasumathi sridharan
>            Priority: Minor
>
> The [ThresholdCircuitBreaker impl |https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/concurrent/ThresholdCircuitBreaker.java]
> does not seem to comply with the interface. The [checkState | https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/AbstractCircuitBreaker.html#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
> {code}/**
> 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
>  *     }
>  * }
> */{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)