Skip to content

Commit

Permalink
KAFKA-18131: Improve logs for voters (#18028)
Browse files Browse the repository at this point in the history
Currently, the log of LeaderState#timeUntilCheckQuorumExpires uses streams without a terminal operator, resulting in output like java.util.stream.ReferencePipeline$3@39660237.
This PR aims to fix this issue and improve the log message.

Reviewers: Luke Chen <showuon@gmail.com>
  • Loading branch information
frankvicky authored Jan 6, 2025
1 parent b9354d6 commit 2e4a378
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion raft/src/main/java/org/apache/kafka/raft/LeaderState.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ public long timeUntilCheckQuorumExpires(long currentTimeMs) {
"Current fetched voters are {}, and voters are {}",
checkQuorumTimeoutMs,
fetchedVoters,
voterStates.values().stream().map(voter -> voter.replicaKey)
voterStates.values()
.stream()
.map(voter -> voter.replicaKey)
.collect(Collectors.toUnmodifiableSet())
);
}
return remainingMs;
Expand Down
2 changes: 1 addition & 1 deletion raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int hashCode() {

@Override
public String toString() {
return String.format("ReplicaKey(id=%d, directoryId=%s)", id, directoryId);
return String.format("ReplicaKey(id=%d, directoryId=%s)", id, directoryId.map(Uuid::toString).orElse("<undefined>"));
}

public static ReplicaKey of(int id, Uuid directoryId) {
Expand Down

0 comments on commit 2e4a378

Please sign in to comment.