public Optional<Map.Entry<Long, LogSegment>> lastEntry() {
        return Optional.ofNullable(segments.lastEntry());
    }
Return the entry associated with the greatest offset, if it exists.

This method is thread-safe.
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegments.java