Skip to content

Commit 2e4a378

Browse files
authored
KAFKA-18131: Improve logs for voters (apache#18028)
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 <[email protected]>
1 parent b9354d6 commit 2e4a378

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

raft/src/main/java/org/apache/kafka/raft/LeaderState.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ public long timeUntilCheckQuorumExpires(long currentTimeMs) {
156156
"Current fetched voters are {}, and voters are {}",
157157
checkQuorumTimeoutMs,
158158
fetchedVoters,
159-
voterStates.values().stream().map(voter -> voter.replicaKey)
159+
voterStates.values()
160+
.stream()
161+
.map(voter -> voter.replicaKey)
162+
.collect(Collectors.toUnmodifiableSet())
160163
);
161164
}
162165
return remainingMs;

raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public int hashCode() {
7070

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

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

0 commit comments

Comments
 (0)