Skip to content

Commit

Permalink
Replace Queue#poll with #remove since that is the expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Jun 11, 2018
1 parent f2e53fa commit 1353b1e
Showing 1 changed file with 4 additions and 7 deletions.
Expand Up @@ -244,12 +244,9 @@ public Optional<RaftMessages.RaftMessage> maybeComplete( Queue<Long> terms, Queu
RaftLogEntry[] entries = new RaftLogEntry[entryCount]; RaftLogEntry[] entries = new RaftLogEntry[entryCount];
for ( int i = 0; i < entryCount; i++ ) for ( int i = 0; i < entryCount; i++ )
{ {
Long term = terms.poll(); long term = terms.remove();
if ( term == null ) ReplicatedContent content = contents.remove();
{ entries[i] = new RaftLogEntry( term, content );
throw new IllegalArgumentException( "Term cannot be null" );
}
entries[i] = new RaftLogEntry( term, contents.poll() );
} }
return Optional.of( new RaftMessages.AppendEntries.Request( from, term, prevLogIndex, prevLogTerm, entries, leaderCommit ) ); return Optional.of( new RaftMessages.AppendEntries.Request( from, term, prevLogIndex, prevLogTerm, entries, leaderCommit ) );
} }
Expand All @@ -273,7 +270,7 @@ public Optional<RaftMessages.RaftMessage> maybeComplete( Queue<Long> terms, Queu
} }
else else
{ {
return Optional.of( new RaftMessages.NewEntry.Request( from, contents.poll() ) ); return Optional.of( new RaftMessages.NewEntry.Request( from, contents.remove() ) );
} }
} }
} }
Expand Down

0 comments on commit 1353b1e

Please sign in to comment.