hooji opened a new pull request, #1543:
URL: https://github.com/apache/ratis/pull/1543
## What changes were proposed in this pull request?
Fix the `AdminApi.setConfiguration(RaftPeer[] serversInNewConf, RaftPeer[]
listenersInNewConf)` default method. It built its `Arguments` with
```java
.setListenersInNewConf(serversInNewConf)
.setListenersInNewConf(listenersInNewConf)
```
so 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 hit `Preconditions.assertUnique(null)` — every
call to this overload failed with a `NullPointerException`, 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.TestAdminApi` in ratis-test) that captures the built
`Arguments` through a stub `AdminApi` and asserts both two-argument overloads.
Found while evaluating Ratis for adoption; present at `ratis-3.2.2` and on
current master (7eedc1dee).
## What is the link to the Apache JIRA
Apologies — I don't have an ASF JIRA account, so I could not file the issue
first. If a committer can create/assign a RATIS number, please retitle this PR
(or amend on merge); happy to do it myself if an issue link is posted here.
## How was this patch tested?
New unit test `org.apache.ratis.client.TestAdminApi`:
- **Before the fix**: `testSetConfigurationWithArrays` fails with
`java.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)`
- **After the fix**: `Tests run: 2, Failures: 0, Errors: 0, Skipped: 0`
Also ran `checkstyle:check` and `apache-rat:check` on the changed modules
(clean). Built and tested with JDK 21.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]