artemlivshits commented on code in PR #14568: URL: https://github.com/apache/kafka/pull/14568#discussion_r1362959888
########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -1080,9 +1080,9 @@ class UnifiedLog(@volatile var logStartOffset: Long, (updatedProducers, completedTxns.toList, None) } - private def batchMissingRequiredVerification(batch: MutableRecordBatch, requestVerificationGuard: Object): Boolean = { + private def batchMissingRequiredVerification(batch: MutableRecordBatch, requestVerificationGuard: VerificationGuard): Boolean = { producerStateManager.producerStateManagerConfig().transactionVerificationEnabled() && !batch.isControlBatch && - (requestVerificationGuard != verificationGuard(batch.producerId) || requestVerificationGuard == null) + (requestVerificationGuard == null || !requestVerificationGuard.equals(verificationGuard(batch.producerId))) Review Comment: It's not possible to have a collision on comparison of references of 2 separately allocated live objects (unless there is a bug in JVM), there could be collision on the hash codes, but not references. And it's not just because reference is 64 bits, the references of 2 live objects are never the same, this is guaranteed by JVM. It's theoretically possible to get a collision on integers (they are just auto-incremented, after all, nobody tracks that lifetime of an object with one id doesn't overlap with lifetime with object of collided id), though it would require a very long time for a 64 bit integer (shouldn't happen in practice in lifetime of a broker). We definitely have examples of this in Kafka codebase https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/BuiltInPartitioner.java#L164 This one is written by me :-), but I'm pretty sure I've seen this pattern somewhere else in Kafka. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org