Nickstery commented on code in PR #14104: URL: https://github.com/apache/kafka/pull/14104#discussion_r1294052739
########## storage/src/main/java/org/apache/kafka/storage/internals/log/TimeIndex.java: ########## @@ -72,15 +72,17 @@ public TimeIndex(File file, long baseOffset, int maxIndexSize, boolean writable) @Override public void sanityCheck() { TimestampOffset entry = lastEntry(); + long lastTimestamp = entry.timestamp; long lastOffset = entry.offset; - if (entries() != 0 && lastTimestamp < timestamp(mmap(), 0)) - throw new CorruptIndexException("Corrupt time index found, time index file (" + file().getAbsolutePath() + ") has " - + "non-zero size but the last timestamp is " + lastTimestamp + " which is less than the first timestamp " - + timestamp(mmap(), 0)); + Review Comment: Checks have been re-ordered since mmap() is protected method and it is tricky to mock its data when most of segment data is mocked. Since this case `if (entries() != 0 && lastOffset < baseOffset())` does not require mmap() execution I've put it first to be able test this case in unit tests. -- 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