edoardocomar commented on code in PR #21873:
URL: https://github.com/apache/kafka/pull/21873#discussion_r3289909684


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/common/SocketServerMemoryPoolTest.java:
##########
@@ -50,42 +51,31 @@
 })
 public class SocketServerMemoryPoolTest {
     @ClusterTest
-    public void testProduceRequestWithUnsupportedVersion(ClusterInstance 
clusterInstance) throws Exception {
-        short unsupportedVersion = Short.MAX_VALUE;
-        byte[] rawRequestBytes = buildRawRequest(
-                ApiKeys.PRODUCE.id,
-                unsupportedVersion,
-                /* correlationId */ 1,
-                /* clientId     */ "test-unsupported-version",
-                new byte[10000]
-        );
+    public void testRequestWithUnsupportedVersion(ClusterInstance 
clusterInstance) throws Exception {
+        RequestHeader header = 
IntegrationTestUtils.nextRequestHeader(ApiKeys.PRODUCE, Short.MAX_VALUE);
+        ByteBuffer buffer = RequestUtils.serialize(header.data(), 
header.headerVersion(), new ProduceRequestData(), header.apiVersion());
+        byte[] rawRequestBytes = buffer.array();
 
         sendAndAssert(clusterInstance, rawRequestBytes);
     }
 
     @ClusterTest
-    public void testProduceRequestWithCorruptBody(ClusterInstance 
clusterInstance) throws Exception {
-        short validVersion = 3;
-        byte[] corruptBody = new byte[10000];
-        for (int i = 0; i < corruptBody.length; i++) {
-            corruptBody[i] = (byte) 0xFF; // The corrupt body (0xFF ... 0xFF) 
makes Schema.read() throw SchemaException.
+    public void testRequestWithCorruptBody(ClusterInstance clusterInstance) 
throws Exception {
+        RequestHeader header = 
IntegrationTestUtils.nextRequestHeader(ApiKeys.PRODUCE, 
ApiKeys.PRODUCE.latestVersion());
+        ByteBuffer buffer = RequestUtils.serialize(header.data(), 
header.headerVersion(), new ProduceRequestData(), header.apiVersion());
+        byte[] rawRequestBytes = buffer.array();
+
+        // corrupt body but leave header valid

Review Comment:
   nice one



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to