ahuang98 commented on code in PR #17930:
URL: https://github.com/apache/kafka/pull/17930#discussion_r1915413306


##########
raft/src/main/java/org/apache/kafka/raft/RaftUtil.java:
##########
@@ -546,8 +546,11 @@ public static AddRaftVoterResponseData addVoterResponse(
         Errors error,
         String errorMessage
     ) {
-        errorMessage = errorMessage == null ? error.message() : errorMessage;
-
+        if (errorMessage == null) {
+            errorMessage = !Errors.NONE.equals(error) ? error.message() : null;
+        } else if (Errors.NONE.equals(error)) {
+            errorMessage = null;
+        }

Review Comment:
   it might be more concise to just do
   ```
   errorMessage = errorMessage == null ? error.message() : errorMessage;
   if (error == Errors.NONE) {
     errorMessage = null;
   }
   ```
   what do you think about adding a comment as well?
   ```
   // return the provided errorMessage if it exists, Errors.NONE should have a 
null message
   ```
   
   



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to