WencongLiu commented on code in PR #22341: URL: https://github.com/apache/flink/pull/22341#discussion_r1301133436
########## flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMasterServiceLeadershipRunner.java: ########## @@ -338,32 +356,24 @@ private void confirmLeadership( FutureUtils.assertNoException( leaderAddressFuture.thenAccept( address -> { - synchronized (lock) { - if (isValidLeader(leaderSessionId)) { - LOG.debug("Confirm leadership {}.", leaderSessionId); - leaderElection.confirmLeadership(leaderSessionId, address); - } else { - LOG.trace( - "Ignore confirming leadership because the leader {} is no longer valid.", - leaderSessionId); - } - } + runIfValidLeader( + leaderSessionId, + () -> { + LOG.debug("Confirm leadership {}.", leaderSessionId); + leaderElection.confirmLeadership(leaderSessionId, address); + }, + "confirming leadership"); })); } private void forwardResultFuture( UUID leaderSessionId, CompletableFuture<JobManagerRunnerResult> resultFuture) { resultFuture.whenComplete( (jobManagerRunnerResult, throwable) -> { Review Comment: Fixed. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org