jolshan commented on code in PR #13231:
URL: https://github.com/apache/kafka/pull/13231#discussion_r1123503881


##########
clients/src/main/java/org/apache/kafka/common/requests/AddPartitionsToTxnRequest.java:
##########
@@ -118,11 +123,78 @@ public AddPartitionsToTxnRequestData data() {
 
     @Override
     public AddPartitionsToTxnResponse getErrorResponse(int throttleTimeMs, 
Throwable e) {
-        final HashMap<TopicPartition, Errors> errors = new HashMap<>();
-        for (TopicPartition partition : partitions()) {
-            errors.put(partition, Errors.forException(e));
+        Errors error = Errors.forException(e);
+        AddPartitionsToTxnResponseData response = new 
AddPartitionsToTxnResponseData();
+        if (version < 4) {
+            
response.setResultsByTopicV3AndBelow(errorResponseForTopics(data.v3AndBelowTopics(),
 error));
+        } else {
+            AddPartitionsToTxnResultCollection results = new 
AddPartitionsToTxnResultCollection();
+            for (AddPartitionsToTxnTransaction transaction : 
data().transactions()) {
+                
results.add(errorResponseForTransaction(transaction.transactionalId(), error));
+            }
+            response.setResultsByTransaction(results);
+            response.setErrorCode(error.code());

Review Comment:
   To clarify -- I'm not sure if being clear on how we want to use it (ie the 
errors it is used for) is the same question as if we want to include the error 
on the txns as well. 
   
   As for the latter, I think we are more error prone if we set the error to 
none. I guess I'm just not sure what we are trying to accomplish by removing 
them from the lower fields. To be clear, I think I've also seen this pattern on 
other responses with top level errors.



-- 
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