hachikuji commented on a change in pull request #9401:
URL: https://github.com/apache/kafka/pull/9401#discussion_r525586697



##########
File path: 
clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java
##########
@@ -560,13 +562,24 @@ private void handleProduceResponse(ClientResponse 
response, Map<TopicPartition,
             log.trace("Received produce response from node {} with correlation 
id {}", response.destination(), correlationId);
             // if we have a response, parse it
             if (response.hasResponse()) {
+                // TODO: Sender should exercise PartitionProduceResponse 
rather than ProduceResponse.PartitionResponse
+                // https://issues.apache.org/jira/browse/KAFKA-10696

Review comment:
       nit: since we have the jira for tracking, can we remove the TODO? A few 
more of these in the PR.

##########
File path: 
clients/src/test/java/org/apache/kafka/common/requests/ProduceResponseTest.java
##########
@@ -100,16 +113,92 @@ public void produceResponseRecordErrorsTest() {
             ProduceResponse response = new ProduceResponse(responseData);
             Struct struct = response.toStruct(ver);
             assertEquals("Should use schema version " + ver, 
ApiKeys.PRODUCE.responseSchema(ver), struct.schema());
-            ProduceResponse.PartitionResponse deserialized = new 
ProduceResponse(struct).responses().get(tp);
+            ProduceResponse.PartitionResponse deserialized = new 
ProduceResponse(new ProduceResponseData(struct, ver)).responses().get(tp);
             if (ver >= 8) {
                 assertEquals(1, deserialized.recordErrors.size());
                 assertEquals(3, deserialized.recordErrors.get(0).batchIndex);
                 assertEquals("Record error", 
deserialized.recordErrors.get(0).message);
                 assertEquals("Produce failed", deserialized.errorMessage);
             } else {
                 assertEquals(0, deserialized.recordErrors.size());
-                assertEquals(null, deserialized.errorMessage);
+                assertNull(deserialized.errorMessage);
             }
         }
     }
+
+    /**
+     * the schema in this test is from previous code and the automatic 
protocol should be compatible to previous schema.
+     */
+    @Test
+    public void testCompatibility() {

Review comment:
       I think this test might be overkill. We haven't done anything like this 
for the other converted APIs. It's a little similar to 
`MessageTest.testRequestSchemas`, which was useful verifying the generated 
schemas when the message generator was being written. Soon `testRequestSchemas` 
will be redundant, so I guess we have to decide if we just trust the generator 
and our compatibility system tests or if we want some other canonical 
representation. Thoughts?




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

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


Reply via email to