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


##########
clients/src/main/java/org/apache/kafka/common/requests/AddPartitionsToTxnRequest.java:
##########
@@ -118,11 +193,41 @@ 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);
+        if (version < 4) {
+            final HashMap<TopicPartition, Errors> errors = new HashMap<>();
+            for (TopicPartition partition : partitions()) {
+                errors.put(partition, error);
+            }
+            return new AddPartitionsToTxnResponse(throttleTimeMs, errors);
+        } else {
+            AddPartitionsToTxnResponseData response = new 
AddPartitionsToTxnResponseData();

Review Comment:
   Many new APIs do include a top-level error code, so there is definitely 
precedent. I kind of like giving the broker an easy way to indicate a failure 
without requiring it to do a bunch of wasteful work. It's not a common case 
though, so I'm not sure how much it matters.



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