[
https://issues.apache.org/jira/browse/KAFKA-17725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887634#comment-17887634
]
Xiaobing Fang commented on KAFKA-17725:
---------------------------------------
[~chia7712] In my usage, one thread records the consumed messages as map key
(Record.hashCode) and performs some processing, while another thread records
some metrics through the RecordHeaders.lastHeader() method
> 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)