RATIS-2640. Fix AdminApi.setConfiguration(RaftPeer[], RaftPeer[]) dropping the servers array - #1543
Open
hooji wants to merge 1 commit into
Open
RATIS-2640. Fix AdminApi.setConfiguration(RaftPeer[], RaftPeer[]) dropping the servers array#1543hooji wants to merge 1 commit into
hooji wants to merge 1 commit into
Conversation
…rvers array The two-array overload built its Arguments with setListenersInNewConf(serversInNewConf) followed by setListenersInNewConf(listenersInNewConf), so the servers were dropped and the builder's server list stayed null; every call to this overload then failed with a NullPointerException from Preconditions.assertUnique in the Arguments constructor. Route the servers through setServersInNewConf, as the javadoc documents, and add a regression test covering both two-argument overloads. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Sorry, I'm not on JIRA. We just noticed the bug while doing an AI survey of the code prior to making a decision between Ratis and SOFAJRaft. Can you file the JIRA for us? Here's a copy of the final evaluation if you're interested. Written by Fable 5: |
Contributor
@hooji Your request for a Jira user is approved, now you can proceed creating the issue. Thanks. |
Author
|
JIRA 2640 filed |
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.
What changes were proposed in this pull request?
Fix the
AdminApi.setConfiguration(RaftPeer[] serversInNewConf, RaftPeer[] listenersInNewConf)default method. It built itsArgumentswithso the servers array was passed to the listeners setter and then overwritten by the real listeners. The builder's server list was never set, and
Arguments's constructor then hitPreconditions.assertUnique(null)— every call to this overload failed with aNullPointerException, i.e. the overload has never worked as its javadoc documents ("The same as setConfiguration(Arrays.asList(serversInNewConf), Arrays.asList(listenersInNewConf))"). No in-repo caller uses it, which is presumably why it went unnoticed.The fix routes the servers through
setServersInNewConf(...), mirroring the List-based overload directly above it, and adds a regression test (org.apache.ratis.client.TestAdminApiin ratis-test) that captures the builtArgumentsthrough a stubAdminApiand asserts both two-argument overloads.Found while evaluating Ratis for adoption; present at
ratis-3.2.2and on current master (7eedc1d).What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2640
How was this patch tested?
New unit test
org.apache.ratis.client.TestAdminApi:testSetConfigurationWithArraysfails withjava.lang.NullPointerException ... at org.apache.ratis.util.Preconditions.assertUnique(Preconditions.java:142) ... at org.apache.ratis.protocol.SetConfigurationRequest$Arguments.<init>(SetConfigurationRequest.java:59) ... at org.apache.ratis.client.api.AdminApi.setConfiguration(AdminApi.java:65)Tests run: 2, Failures: 0, Errors: 0, Skipped: 0Also ran
checkstyle:checkandapache-rat:checkon the changed modules (clean). Built and tested with JDK 21.🤖 Generated with Claude Code