Skip to content

RATIS-2804. Fix gRPC log-appender.connections conf and code cleanup - #1685

Merged
amaliujia merged 3 commits into
apache:masterfrom
szetszwo:RATIS-2804
Nov 13, 2026
Merged

amaliujia merged 3 commits into
apache:masterfrom
szetszwo:RATIS-2804

Conversation

@szetszwo

@szetszwo szetszwo commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

See RATIS-2804.

Assisted by claude-opus-5-5

@szetszwo
szetszwo requested a review from amaliujia November 6, 2026 18:43

@amaliujia amaliujia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Just a minor comment.

}

/**
* This method must be called only when there are other channels.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an odd contract that the caller has to be aware of otherStubs is not null otherwise this call will hit an NPE.

The best way to avoid it is to make this nextChannelIndex as private thus only this class will use it and we know what we are doing. However I see that we need it in testing as well so have to keep this as package private. But then package private means other Ratis developer might still call it and cause unseen issue when testing is not enough or reviewers not having enough context.

I am wondering if we can return -1 when otherStubs is null? Though still not perfect, it avoids surprising NPE. Meanwhile negative values are often used to indicate something wrong in other languages like C++.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the method is not expected to be called when otherStubs is null, throwing an exception is better. Here is some AI suggestion:

image image

@amaliujia amaliujia Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep throw an exception other than NPE also works.

@szetszwo

Copy link
Copy Markdown
Contributor Author

AI also suggests to throw IllegalStateException instead of NPE. Pushed a change for it.

@amaliujia
amaliujia merged commit 9fd874f into apache:master Nov 13, 2026
33 of 34 checks passed
@szetszwo

Copy link
Copy Markdown
Contributor Author

@amaliujia , thanks for reviewing and merging this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants