Rename static factory methods in LoadBalancer.PickResult to use of* prefix instead of with*
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 37
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.
Contributor guide
Assessment
This issue has not been assessed yet.