mauhiz commented on code in PR #19972: URL: https://github.com/apache/kafka/pull/19972#discussion_r2152124321
########## storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegment.java: ########## @@ -192,8 +192,13 @@ public void sanityCheck(boolean timeIndexFileNewlyCreated) throws IOException { * the time index). */ public TimestampOffset readMaxTimestampAndOffsetSoFar() throws IOException { - if (maxTimestampAndOffsetSoFar == TimestampOffset.UNKNOWN) - maxTimestampAndOffsetSoFar = timeIndex().lastEntry(); + if (maxTimestampAndOffsetSoFar == TimestampOffset.UNKNOWN) { Review Comment: I thought `updateAndGet` could work to this effect ```java maxTimestampAndOffsetSoFar.updateAndGet(t -> if (t == TimestampOffset.UNKNOWN) timeIndex().lastEntry() else t) ``` But I have not fully considered whether it would end up being slower on any microbenchmark. It just looked simpler. -- 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