You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "szetszwo (via GitHub)" <gi...@apache.org> on 2023/02/01 12:15:25 UTC
[GitHub] [ratis] szetszwo commented on a diff in pull request #817: RATIS-1778. Fix NPE in readIndexHeartbeats
szetszwo commented on code in PR #817:
URL: https://github.com/apache/ratis/pull/817#discussion_r1093141197
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ReadIndexHeartbeats.java:
##########
@@ -101,7 +101,7 @@ boolean receive(LogAppender logAppender, AppendEntriesReplyProto proto,
final HeartbeatAck reply = replies.computeIfAbsent(
logAppender.getFollowerId(), key -> new HeartbeatAck(logAppender));
if (reply.receive(proto)) {
- if (hasMajority.test(id -> replies.get(id).isAcknowledged())) {
+ if (hasMajority.test(id -> replies.get(id) != null && replies.get(id).isAcknowledged())) {
Review Comment:
Let's use `Optional` to add an `isAcknowledged` method:
```java
boolean isAcknowledged(RaftPeerId id) {
return Optional.ofNullable(replies.get(id)).map(HeartbeatAck::isAcknowledged).isPresent();
}
```
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org