m1a2st commented on code in PR #23665:
URL: https://github.com/apache/kafka/pull/23665#discussion_r4314672067


##########
clients/src/main/java/org/apache/kafka/common/requests/RequestHeader.java:
##########
@@ -152,7 +168,7 @@ public static RequestHeader parse(ByteBuffer buffer) {
             if (!apiKey.hasValidVersion())
                 throw new InvalidRequestException("Unsupported api with key " 
+ apiKeyId + " (" + apiKey.name + ") and version " + apiVersion);
 
-            short headerVersion = apiKey.requestHeaderVersion(apiVersion);
+            short headerVersion = apiKey.isVersionSupported(apiVersion) ? 
apiKey.requestHeaderVersion(apiVersion) : (short) 1;

Review Comment:
   I'd prefer to keep the parsing in the generated code. Hand-written parsing 
would duplicate the decoding logic outside the schema.
   
   I agree that v1 only happens to match the four common fields today, so I've 
made that explicit, `RequestHeader.json` now specifies that the first four 
fields must retain their order and encoding, and that v1 must not be removed 
because brokers use it to parse headers with unsupported API versions.
   



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