ijuma commented on a change in pull request #10393: URL: https://github.com/apache/kafka/pull/10393#discussion_r608209771
########## File path: raft/src/main/java/org/apache/kafka/raft/CandidateState.java ########## @@ -235,6 +240,15 @@ public int epoch() { return highWatermark; } + @Override + public boolean canGrantVote(int candidateId, boolean isLogUpToDate) { + // Still reject vote request even candidateId = localId, Although the candidate votes for + // itself, this vote is implicit and not "granted". + log.debug("Rejecting vote request from candidate {} since we are already candidate in epoch {}", + candidateId, epoch); Review comment: I think it's a misguided goal to reduce cyclomatic complexity if it results in surprising code. Generally, predicate type methods (`isX` or `canX`) should be callable multiple types without undesired behavior like several log lines. Maybe you can address this in a subsequent PR? -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org