Repository navigation
Conversation
…eplication level Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix addresses the NPE and the updated test reliably exercises the affected path.
0 open findings
What changed in this PR
Fixes the null-message NPE in custom-replication writes and strengthens regression coverage.
Changes:
- Reuses the null-safe dummy-request check in watch and read paths.
- Waits for and validates every asynchronous test reply.
| File | Description |
|---|---|
RaftServerImpl.java |
Safely handles internal watch requests without messages. |
RaftAsyncTests.java |
Ensures custom-replication writes complete successfully. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
amaliujia
reviewed
Oct 10, 2026
| futures.add(client.async().send(new SimpleMessage(s), ReplicationLevel.ALL_COMMITTED)); | ||
| } | ||
| for (CompletableFuture<RaftClientReply> f : futures) { | ||
| final RaftClientReply reply = getWithDefaultTimeout(f); |
Contributor
There was a problem hiding this comment.
if (exception != null) {
LOG.error("Failed to send message " + s, exception);
// reply should be null in case of exception
Assertions.assertNull(reply);
return;
}
This code has been dropped. Is it because the NPE is gone?
Contributor
|
@smengcl , thanks for working on this! We need to update it for RATIS-2724. Otherwise, the change looks good. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated-by: Claude Code (Opus 5.5)
What changes were proposed in this pull request?
A write sent with a replication level other than MAJORITY, for example
client.async().send(message, ReplicationLevel.ALL_COMMITTED), never succeeds. After the write is applied,RaftServerImpl.waitForReplicationbuilds an internal watch request without a message, and the dummy request check that RATIS-2497 added toRaftServerImpl.watchAsynccallsrequest.getMessage().getContent()on it. The leader throws a NullPointerException, and the client keeps retrying according to its retry policy.RaftServerImplalready has a null safe version of that check,isDummyRead, used on the read path. This change uses it inwatchAsyncas well and renames it toisDummy.RaftAsyncTests.testWriteAsyncCustomReplicationLeveldid not catch this because it never waited for the futures returned bysend. The client was closed before any reply arrived, every future completed withAlreadyClosedException, and the callback only logged it. The test now waits for each reply and fails on an exception.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2734
How was this patch tested?
testWriteAsyncCustomReplicationLevelwith the stricter assertions fails without the fix and passes with it inTestRaftAsyncWithGrpc,TestRaftAsyncWithGrpcTracingandTestRaftAsyncWithNetty.TestLinearizableReadWithGrpcpasses with the renamed check.🤖 Generated with Claude Code