Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-521

LeaderLatch closed with CloseMode=null does not close

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 4.2.0
    • 5.6.0
    • Recipes
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              tison Zili Chen
              yuri.tceretian Yuri Tceretian
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: