[
https://issues.apache.org/jira/browse/KAFKA-17725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887628#comment-17887628
]
Chia-Ping Tsai commented on KAFKA-17725:
----------------------------------------
Not only the key, but also the value is not thread-safe. This is the expected
behavior. Could you please share your use case?
> RecordHeader key() is not thread safe
> -------------------------------------
>
> Key: KAFKA-17725
> URL: https://issues.apache.org/jira/browse/KAFKA-17725
> Project: Kafka
> Issue Type: Bug
> Components: clients
> Reporter: Xiaobing Fang
> Priority: Major
>
> {code:java}
> public String key() {
> if (key == null) {
> key = Utils.utf8(keyBuffer, keyBuffer.remaining());
> keyBuffer = null;
> }
> return key;
> } {code}
> This method in RecordHeader is not thread safe.
> It may throw NPE when it is accessed concurrently by multiple threads,
> because keyBuffer maybe null by pre thread.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)