Skip to content

Commit

Permalink
CURATOR-521. Check LeaderLatch#close(CloseMode) does not accept null (#…
Browse files Browse the repository at this point in the history
…481)

Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun authored Sep 19, 2023
1 parent 51483ad commit 3468ee9
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ void closeOnDemand() throws IOException {
* @throws IOException errors
*/
public void close(CloseMode closeMode) throws IOException {
Preconditions.checkNotNull(closeMode, "closeMode cannot be null");
internalClose(closeMode, true);
}

Expand All @@ -200,8 +201,6 @@ private synchronized void internalClose(CloseMode closeMode, boolean failOnClose
}
}

Preconditions.checkNotNull(closeMode, "closeMode cannot be null");

cancelStartTask();

try {
Expand All @@ -214,17 +213,14 @@ private synchronized void internalClose(CloseMode closeMode, boolean failOnClose
client.getConnectionStateListenable().removeListener(listener);

switch (closeMode) {
case NOTIFY_LEADER: {
case NOTIFY_LEADER:
setLeadership(false);
listeners.clear();
break;
}

default: {
case SILENT:
listeners.clear();
setLeadership(false);
break;
}
}
}
}
Expand Down Expand Up @@ -457,13 +453,12 @@ public boolean hasLeadership() {
* it is possible for <code>null</code> to be returned. The path, if any,
* returned is not guaranteed to be valid at any point in the future as internal
* state changes might require the instance to delete and create a new path.
*
* <p>
* However, the existence of <code>ourPath</code> doesn't mean that this instance
* holds leadership.
*
* @see #getLastPathIsLeader
*
* @return lock node path or <code>null</code>
* @see #getLastPathIsLeader
*/
public String getOurPath() {
return ourPath.get();
Expand All @@ -475,7 +470,7 @@ public String getOurPath() {
* Also, it is possible for <code>null</code> to be returned (for this instance never becomes
* a leader). The path, if any, returned is not guaranteed to be valid at any point in the future
* as internal state changes might require the instance to delete the path.
*
* <p>
* The existence of <code>lastPathIsLeader</code> means that this instance holds leadership.
*
* @return last lock node path that was leader ever or <code>null</code>
Expand Down

0 comments on commit 3468ee9

Please sign in to comment.