tisonkun commented on code in PR #430: URL: https://github.com/apache/curator/pull/430#discussion_r974852280
########## curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java: ########## @@ -198,9 +204,25 @@ public void close() throws IOException * @param closeMode allows the default close mode to be overridden at the time the latch is closed. * @throws IOException errors */ - public synchronized void close(CloseMode closeMode) throws IOException + public void close(CloseMode closeMode) throws IOException { - Preconditions.checkState(state.compareAndSet(State.STARTED, State.CLOSED), "Already closed or has not been started"); + internalClose(closeMode, true); + } + + private synchronized void internalClose(CloseMode closeMode, boolean failOnClosed) throws IOException + { + if (!state.compareAndSet(State.STARTED, State.CLOSED)) + { + if (failOnClosed) + { + throw new IllegalStateException("Already closed or has not been started"); + } + else + { + return; + } Review Comment: Make sense. Although, they're almost the same. So I just keep it as is now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@curator.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org