This method is only ever called by SegmentedJournalReader, inline it
there. This removes one source of the magic 0 index.
JIRA: CONTROLLER-2106
Change-Id: I0fcb16e806d027d22f8e6370788aab21884c9e71
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
firstIndex = segment.index();
}
- /**
- * Returns the current reader index.
- *
- * @return The current reader index.
- */
- final long getCurrentIndex() {
- return currentEntry != null ? currentEntry.index() : 0;
- }
-
/**
* Returns the last read entry.
*
@Override
public final long getCurrentIndex() {
- long currentIndex = currentReader.getCurrentIndex();
- if (currentIndex != 0) {
- return currentIndex;
- }
- if (previousEntry != null) {
- return previousEntry.index();
+ final var currentEntry = currentReader.getCurrentEntry();
+ if (currentEntry != null) {
+ final long currentIndex = currentEntry.index();
+ if (currentIndex != 0) {
+ return currentIndex;
+ }
}
- return 0;
+ return previousEntry != null ? previousEntry.index() : 0;
}
@Override