[ https://issues.apache.org/jira/browse/KAFKA-2312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tim Brooks updated KAFKA-2312: ------------------------------ Attachment: KAFKA-2312.patch > Use AtomicLong opposed to AtomicReference to store currentThread in consumer > ---------------------------------------------------------------------------- > > Key: KAFKA-2312 > URL: https://issues.apache.org/jira/browse/KAFKA-2312 > Project: Kafka > Issue Type: Improvement > Components: clients > Reporter: Tim Brooks > Priority: Minor > Attachments: KAFKA-2312.patch > > > When a thread id is returned by Thread.currentThread().getId() it is a > primitive. Storing it in an AtomicReference requires boxing and additional > indirection. > An AtomicLong seems more natural to store a long. > The current implementation relies on knowing that null means no owner. Since > thread ids are always positive (specified in javadoc), it is possible to > create a constant NO_CURRENT_THREAD for -1. Which allows the usage of an > AtomicLong and makes the functionality explicit. -- This message was sent by Atlassian JIRA (v6.3.4#6332)