ijuma commented on a change in pull request #7409: URL: https://github.com/apache/kafka/pull/7409#discussion_r535876326
########## File path: clients/src/main/java/org/apache/kafka/common/requests/AbstractResponse.java ########## @@ -84,148 +95,151 @@ protected void updateErrorCounts(Map<Errors, Integer> errorCounts, Errors error) errorCounts.put(error, count + 1); } - protected abstract Struct toStruct(short version); + protected abstract Message data(); /** * Parse a response from the provided buffer. The buffer is expected to hold both * the {@link ResponseHeader} as well as the response payload. */ - public static AbstractResponse parseResponse(ByteBuffer byteBuffer, RequestHeader requestHeader) { + public static AbstractResponse parseResponse(ByteBuffer buffer, RequestHeader requestHeader) { ApiKeys apiKey = requestHeader.apiKey(); short apiVersion = requestHeader.apiVersion(); - ResponseHeader responseHeader = ResponseHeader.parse(byteBuffer, apiKey.responseHeaderVersion(apiVersion)); + ResponseHeader responseHeader = ResponseHeader.parse(buffer, apiKey.responseHeaderVersion(apiVersion)); + AbstractResponse response = AbstractResponse.parseResponse(apiKey, buffer, apiVersion); + + // We correlate after parsing the response to avoid spurious correlation errors when receiving malformed + // responses Review comment: TODO: Handle this better. ---------------------------------------------------------------- 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