Skip to content

Commit

Permalink
refactor: use parameter instead of object
Browse files Browse the repository at this point in the history
Instead of holding the object reference in the lambda use the commitIndex parameter

(cherry picked from commit a88be3e)
  • Loading branch information
ChrisKujawa authored and github-actions[bot] committed Sep 27, 2023
1 parent 236b0fe commit 6477151
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,7 @@ private void replicate(final IndexedRaftLogEntry indexed, final AppendListener a
raft.checkThread();
final var appendEntriesFuture = appender.appendEntries(indexed.index());

final boolean applicationEntryWasCommitted = indexed.isApplicationEntry();
if (applicationEntryWasCommitted) {
if (indexed.isApplicationEntry()) {
// We have some services which are waiting for the application records, especially position
// to be committed. This is our glue code to notify them, instead of
// passing the complete object (IndexedRaftLogEntry) threw the listeners and
Expand Down Expand Up @@ -632,11 +631,11 @@ private void replicate(final IndexedRaftLogEntry indexed, final AppendListener a
// up to date with the latest entries, so it can handle configuration and initial
// entries properly on fail over
if (commitError == null) {
appendListener.onCommit(indexed.index());
appendListener.onCommit(commitIndex);
} else {
appendListener.onCommitError(indexed.index(), commitError);
appendListener.onCommitError(commitIndex, commitError);
// replicating the entry will be retried on the next append request
log.error("Failed to replicate entry: {}", indexed, commitError);
log.error("Failed to replicate entry: {}", commitIndex, commitError);
}
},
raft.getThreadContext());
Expand Down

0 comments on commit 6477151

Please sign in to comment.