-
Notifications
You must be signed in to change notification settings - Fork 14.7k
KAFKA-19644: Enhance the documentation for producer headers and integration tests #20524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yunyung
Thanks for the patch, I just left a minor comment for your consideration.
...integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerTest.java
Show resolved
Hide resolved
headerKey: String | ||
headerValueLength: varint | ||
Value: byte[]</code></pre> | ||
<p>The key of a record header is guaranteed to be non-null, while the value of a record header may be null. The order of headers in a record is preserved when producing and consuming.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add comments to the public API Header
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@ClusterTest | ||
public void testClassicConsumerHeadersOrderPreserved() throws Exception { | ||
testHeadersOrderPreserved(Map.of( | ||
GROUP_PROTOCOL_CONFIG, GroupProtocol.CLASSIC.name().toLowerCase(Locale.ROOT) | ||
)); | ||
} | ||
|
||
@ClusterTest | ||
public void testAsyncConsumerHeadersOrderPreserved() throws Exception { | ||
testHeadersOrderPreserved(Map.of( | ||
GROUP_PROTOCOL_CONFIG, GroupProtocol.CONSUMER.name().toLowerCase(Locale.ROOT) | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move testClassicConsumerHeadersOrderPreserved
and testAsyncConsumerHeadersOrderPreserved
methods under the testHeaders
test and group the related ones together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks for the review, all! Updated based on the comments. |
package org.apache.kafka.common.header; | ||
|
||
/** | ||
* The key of a header is guaranteed to be non-null, while the value of a header may be null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the comments to each method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks.
the flaky is traced by KAFKA-7542 |
} | ||
|
||
@Test | ||
public void testAddHeadersPreserveOder() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Oder
-> Order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* @param key to return the headers for; must not be null. | ||
* @return all headers for the given key, in the order they were added in, if NO headers are present an empty iterable is returned. | ||
*/ | ||
Iterable<Header> headers(String key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add documents and ut for the Iterable#remove
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thanks!
|
||
/** | ||
* Returns all headers for the given key, in the order they were added in, if present. | ||
* The returned iterators {@link org.apache.kafka.common.utils.AbstractIterator#remove()} always throws {@link UnsupportedOperationException}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractIterator
is not a public API. Perhaps we could just state the Iterable#remove
is unsupported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Updated.
…ation tests (apache#20524) - Improve the docs for Record Headers. - Add integration tests to verify that the order of headers in a record is preserved when producing and consuming. - Add unit tests for RecordHeaders.java. Reviewers: Ken Huang <[email protected]>, Hong-Yi Chen <[email protected]>, Chia-Ping Tsai <[email protected]>
is preserved when producing and consuming.
Reviewers: Ken Huang [email protected], Hong-Yi Chen
[email protected], Chia-Ping Tsai [email protected]