You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Yuri Tceretian (JIRA)" <ji...@apache.org> on 2019/05/21 19:16:00 UTC

[jira] [Created] (CURATOR-521) LeaderLatch closed with CloseMode=null does not close

Yuri Tceretian created CURATOR-521:
--------------------------------------

             Summary: LeaderLatch closed with CloseMode=null does not close 
                 Key: CURATOR-521
                 URL: https://issues.apache.org/jira/browse/CURATOR-521
             Project: Apache Curator
          Issue Type: Bug
          Components: Recipes
    Affects Versions: 4.2.0
            Reporter: Yuri Tceretian


The class LeaderLatch has two methods `close`, one of them accepts argument `CloseMode`. If the argument is null (unlikely but still possible) the instance changes the state to CLOSED but does not really close anything because throws a runtime exception `closeMode cannot be null` right after changing the status.

[https://github.com/apache/curator/blob/a3514d87b1036716e5dc9877c9980fdd81440458/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java#L201-L205]

The quickest fix is to just swap preconditions checks. The more correct solution is to change state in the try block after the client removed all watchers (or in finally block). It should not break anything because the method is synchronized.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)