This is an automated email from the ASF dual-hosted git repository.

cmccabe pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/4.0 by this push:
     new ef9f6fb7fec KAFKA-18131: Improve logs for voters (#18028)
ef9f6fb7fec is described below

commit ef9f6fb7fecf18f18887d3ee94187fc012d681dc
Author: TengYao Chi <[email protected]>
AuthorDate: Mon Jan 6 18:12:46 2025 +0800

    KAFKA-18131: Improve logs for voters (#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]>
---
 raft/src/main/java/org/apache/kafka/raft/LeaderState.java | 5 ++++-
 raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java  | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/raft/src/main/java/org/apache/kafka/raft/LeaderState.java 
b/raft/src/main/java/org/apache/kafka/raft/LeaderState.java
index dffee814d72..36579499e62 100644
--- a/raft/src/main/java/org/apache/kafka/raft/LeaderState.java
+++ b/raft/src/main/java/org/apache/kafka/raft/LeaderState.java
@@ -156,7 +156,10 @@ public class LeaderState<T> implements EpochState {
                 "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;
diff --git a/raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java 
b/raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java
index a1acc39d57c..f25a1d55ba4 100644
--- a/raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java
+++ b/raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java
@@ -70,7 +70,7 @@ public final class ReplicaKey implements 
Comparable<ReplicaKey> {
 
     @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) {

Reply via email to