Skip to content

Commit

Permalink
Fix: don't crash if AppendEntries is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-scott committed Aug 8, 2015
1 parent be4f00a commit 6c81d34
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/scala/pl/project13/scala/akka/raft/Follower.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ private[raft] trait Follower {
msg.term < m.currentTerm

def append(entries: immutable.Seq[Entry[Command]], m: Meta): AppendSuccessful = {
val atIndex = entries.map(_.index).min
log.debug("executing: replicatedLog = replicatedLog.append({}, {})", entries, atIndex)
if (!entries.isEmpty) {
val atIndex = entries.map(_.index).min
log.debug("executing: replicatedLog = replicatedLog.append({}, {})", entries, atIndex)

replicatedLog = replicatedLog.append(entries, atIndex)
// log.debug("log after append: " + replicatedLog.entries)
replicatedLog = replicatedLog.append(entries, take=atIndex-1)

This comment has been minimized.

Copy link
@colin-scott

colin-scott Aug 8, 2015

Author Member

Woops, this is for another commit: making the log 1-indexed

}
AppendSuccessful(replicatedLog.lastTerm, replicatedLog.lastIndex)
}

Expand Down

0 comments on commit 6c81d34

Please sign in to comment.