slfan1989 commented on code in PR #1281:
URL: https://github.com/apache/ratis/pull/1281#discussion_r2366012249
##########
ratis-server/src/test/java/org/apache/ratis/WatchRequestTests.java:
##########
@@ -302,7 +302,6 @@ static void checkAll(List<CompletableFuture<WatchReplies>>
watches, Logger log)
final WatchReplies watchReplies = watches.get(i).get(GET_TIMEOUT_SECOND,
TimeUnit.SECONDS);
final long logIndex = watchReplies.logIndex;
log.info("checkAll {}: logIndex={}", i, logIndex);
- final RaftClientReply watchAllReply = watchReplies.getAll();
Review Comment:
@adoroszlai I’ve analyzed this error in detail, but I still don’t fully
understand why the NPE is triggered. Below is the flow I’ve worked through —
could you and @szetszwo please take a look and let me know if I’ve missed
anything, or share any suggestions?
The failing test case:
`TestWatchRequestWithGrpc#testWatchRequestAsyncChangeLeader`
Error stack trace:
```
at org.apache.ratis.WatchRequestTests.checkAll(WatchRequestTests.java:305)
at
org.apache.ratis.WatchRequestTests.runTestWatchRequestAsyncChangeLeader(WatchRequestTests.java:370)
```
The issue occurs at line 305 in checkAll, corresponding to the following
code:
```
RaftClientReply getAll() throws Exception {
return get(all, "all");
}
RaftClientReply get(CompletableFuture<RaftClientReply> f, String name)
throws Exception {
final RaftClientReply reply = f.get(GET_TIMEOUT_SECOND, TimeUnit.SECONDS);
...
}
```
Here, all is null, so calling f.get(...) results in a NPE.
The value of all comes from:
```
new WatchReplies(logIndex,
...
writeClient.async().watch(logIndex, ReplicationLevel.ALL),
...
log)
```
From this, the only possible explanation is that
`writeClient.async().watch(logIndex, ReplicationLevel.ALL)` returned `null`,
which caused WatchReplies.all to be null and eventually led to the NPE inside
checkAll.
--
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]