Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ private void removeStateMachineDataIfNeeded(long index) {
RaftServer.Division division = ratisServer.getServer().getDivision(getGroupId());
if (division.getInfo().isLeader()) {
long minIndex = Arrays.stream(division.getInfo()
.getFollowerNextIndices()).min().getAsLong();
.getFollowerNextIndices()).min().orElse(0);
LOG.debug("Removing data corresponding to log index {} min index {} "
+ "from cache", index, minIndex);
removeCacheDataUpTo(Math.min(minIndex, index));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jojochuang for the patch.

Should it removeCacheDataUpTo only if minIndex is found?

Arrays.stream(division.getInfo().getFollowerNextIndices())
    .min()
    .ifPresent(minIndex -> removeCacheDataUpTo(Math.min(minIndex, index)));

Also, would be nice to rethrow unchecked exceptions directly:

try {
  ...
} catch (RuntimeException e) {
  throw e;
} catch (Exception e) {
  throw new RuntimeException(e);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's essentially the same, but your suggest is more readable. Will update accordingly.

Expand Down