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


##########
clients/src/main/java/org/apache/kafka/common/requests/RequestContext.java:
##########
@@ -109,11 +110,31 @@ public RequestContext(RequestHeader header,
         this.principalSerde = principalSerde;
     }
 
+    /**
+     * Parses the request body from the given buffer, which must be positioned 
at the start of the request body.
+     * If the header indicates the request version is unsupported, the request 
body is not parsed. An unsupported
+     * {@link ApiVersionsRequest} is treated as a v0 request. For other 
requests, an UnsupportedVersionException is thrown.
+     * <p>
+     * This allows the broker to handle {@link ApiVersionsRequest} from newer 
clients, which uses a request version
+     * unknown to the broker. The broker responds with a v0 {@link 
ApiVersionsResponse} in that case, and the client
+     * falls back to parsing the response as v0 if it cannot parse it as the 
expected version.

Review Comment:
   How about the following?
   
    Parses the request body from the given buffer, which must be positioned at 
the start of the request body.
    If the header indicates the request version is unsupported, the request 
body is not parsed. For all unsupported requests other than {@link 
ApiVersionsRequest} , an UnsupportedVersionException is thrown. An unsupported 
{@link ApiVersionsRequest} could come from new clients and is treated specially 
as a v0 request. The broker responds with a v0 {@link ApiVersionsResponse} 
including the supported versions of {@link ApiVersionsRequest}. If the client 
can't parse the response with the version in the original request it sent, it 
falls back to parsing the response as v0.  This allows the new client to 
discover the version of {@link ApiVersionsRequest} supported by the broker.



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