jsancio commented on code in PR #16892:
URL: https://github.com/apache/kafka/pull/16892#discussion_r1719044640
##########
raft/src/main/java/org/apache/kafka/raft/internals/VoterSetHistory.java:
##########
@@ -83,13 +83,9 @@ public Optional<VoterSet> valueAtOrBefore(long offset) {
* Returns the latest set of voters.
*/
public VoterSet lastValue() {
- Optional<LogHistory.Entry<VoterSet>> result =
votersHistory.lastEntry();
- if (result.isPresent()) {
- return result.get().value();
- }
-
- return staticVoterSet
- .orElseThrow(() -> new IllegalStateException("No voter set
found"));
+ return votersHistory.lastEntry()
+ .map(LogHistory.Entry::value)
+ .orElse(staticVoterSet);
Review Comment:
Yes. In that case they caller would use `lastEntry` which returns an
`Optional<LogHistory.Entry<VoterSet>>`.
There are a couple of cases when the leader wants to know only the latest
voter set that is in the log/partition and not static voter set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]