Skip to content

Commit 49623cb

Browse files
committed
explicitly catch exception and handle it
1 parent d45cc11 commit 49623cb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,17 @@ private void handleJoinRequest(JoinRequest joinRequest, JoinCallback joinCallbac
110110
transportService.connectToNode(joinRequest.getSourceNode());
111111

112112
final Optional<Join> optionalJoin = joinRequest.getOptionalJoin();
113-
final boolean justBecameLeader = optionalJoin.isPresent() && joinHandler.test(optionalJoin.get());
113+
final boolean justBecameLeader;
114+
if (optionalJoin.isPresent()) {
115+
try {
116+
justBecameLeader = joinHandler.test(optionalJoin.get());
117+
} catch (CoordinationStateRejectedException e) {
118+
joinCallback.onFailure(e);
119+
return;
120+
}
121+
} else {
122+
justBecameLeader = false;
123+
}
114124

115125
synchronized (mutex) {
116126
joinAccumulator.handleJoinRequest(joinRequest.getSourceNode(), joinCallback);

0 commit comments

Comments
 (0)