-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
The LoadBalancer.PickResult class currently uses the with* prefix for its static factory methods, such as withSubchannel(), withError(), and withDrop(). In the gRPC-Java library, the with prefix is a well-established convention for instance methods that return a modified copy of an immutable object (e.g., CallOptions.withDeadline() or Status.withCause()). Using with for static creation methods is inconsistent with the rest of the library and is confusing for developers.
This conflict was recently highlighted during the implementation of subchannel unwrapping (PR #12658), where new instance methods had to be named copyWithSubchannel() and copyWithStreamTracerFactory() to avoid collisions and semantic confusion with the existing static methods.
We will replace the existing static with* methods in PickResult with of* naming convention (or similar) to align with standard Java and gRPC-Java factory patterns. Long-term, this cleanup will allow the added instance methods (copyWithSubchannel, etc.) to be renamed to use the standard with prefix (e.g., withSubchannel()), bringing PickResult into full alignment with the library's immutable update patterns.