Menu

#27 hasMore() return wrong value in FeedCursor class

open
nobody
5
2009-11-23
2009-11-23
No

The hasMore() method in com.ibm.tuningfork.infra.feed.FeedCursor has a bug logic.
The current one is
public boolean hasMore() {
return (index > 0 && index < feed.numberOfEvents()) && beforeEndOfRange(feed.getEvent(index).getTime());
}
It will return false in a new cursor since the new cursor's index == 0.
For example in seekToTime() method
public void seekToTime(long time) {
index = (forward ? 0 : feed.numberOfEvents() - 1);
while (hasMore()) {
... ...
}
}
The index was assigned to 0 in forward mode, and the has to more will return false. The result is the cursor cannot seek to the right time.

The fix should change "index > 0" to "index >= 0" in hasMore() method

Discussion


Log in to post a comment.

MongoDB Logo MongoDB