Browse Source

MINOR: fix compatibility-breaking bug in RequestHeader (#7479)

Reviewers: David Arthur <mumrah@gmail.com>, Jason Gustafson <jason@confluent.io>, Ismael Juma <ismael@juma.me.uk>
pull/7494/head
Colin Patrick McCabe 5 years ago committed by GitHub
parent
commit
5c4bbf9344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      clients/src/main/resources/common/message/RequestHeader.json
  2. 2
      clients/src/test/java/org/apache/kafka/common/requests/RequestHeaderTest.java

8
clients/src/main/resources/common/message/RequestHeader.json

@ -30,7 +30,13 @@ @@ -30,7 +30,13 @@
"about": "The API version of this request." },
{ "name": "CorrelationId", "type": "int32", "versions": "0+",
"about": "The correlation ID of this request." },
// The ClientId string must be serialized with the old-style two-byte length prefix.
// The reason is that older brokers must be able to read the request header for any
// ApiVersionsRequest, even if it is from a newer version.
// Since the client is sending the ApiVersionsRequest in order to discover what
// versions are supported, the client does not know the best version to use.
{ "name": "ClientId", "type": "string", "versions": "1+", "nullableVersions": "1+", "ignorable": true,
"about": "The client ID string." }
"flexibleVersions": "none", "about": "The client ID string." }
]
}

2
clients/src/test/java/org/apache/kafka/common/requests/RequestHeaderTest.java

@ -69,7 +69,7 @@ public class RequestHeaderTest { @@ -69,7 +69,7 @@ public class RequestHeaderTest {
RequestHeader header = new RequestHeader(ApiKeys.CREATE_DELEGATION_TOKEN, (short) 2, "", 10);
assertEquals(2, header.headerVersion());
ByteBuffer buffer = toBuffer(header.toStruct());
assertEquals(10, buffer.remaining());
assertEquals(11, buffer.remaining());
RequestHeader deserialized = RequestHeader.parse(buffer);
assertEquals(header, deserialized);
}

Loading…
Cancel
Save