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


##########
clients/src/main/java/org/apache/kafka/common/requests/RequestContext.java:
##########
@@ -148,17 +174,28 @@ public Send buildResponseSend(AbstractResponse body) {
      * so we do not lose the benefit of "zero copy" transfers from disk.
      */
     public ByteBuffer buildResponseEnvelopePayload(AbstractResponse body) {
-        return body.serializeWithHeader(header.toResponseHeader(), 
apiVersion());
+        short version = effectiveApiVersion();
+        return body.serializeWithHeader(responseHeader(version), version);
     }
 
-    private boolean isUnsupportedApiVersionsRequest() {
-        return header.apiKey() == API_VERSIONS && 
!header.isApiVersionSupported();
+    private ResponseHeader responseHeader(short responseVersion) {
+        return new ResponseHeader(header.correlationId(), 
header.apiKey().responseHeaderVersion(responseVersion));
     }
 
-    public short apiVersion() {
-        // Use v0 when serializing an unhandled ApiVersion response
-        if (isUnsupportedApiVersionsRequest())
-            return 0;
+    private boolean isApiVersionsFallback() {
+        return header.apiKey().isFallbackVersion(header.apiVersion());

Review Comment:
   I'm fine with reverting to the previous approach to unblock this PR.
   
   To clarify my point: I wasn't attached to ApiKeys. What I wanted is for the 
v0 fallback to live in a single place. Right now that handshake is spread 
across NetworkClient, ApiVersionsResponse, RequestContext, and 
ApiKeys#isVersionEnabled, and each of them hardcodes 0. Since the fallback is a 
protocol behavior that spans both client and server, it seems better to group 
it by feature rather than by layer, together with a test that guards v0 from 
being removed.
   
   I'll file a follow-up ticket for it.



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