Skip to content

Commit

Permalink
api: When forwarding from Listener onAddresses to Listener2 continue …
Browse files Browse the repository at this point in the history
…to use onResult (#11666) (#11688)

When forwarding from Listener onAddresses to Listener2 continue to use onResult and not onResult2 because the latter requires to be called from within synchronization context and it breaks existing code that didn't need to do so when using the old Listener interface.
  • Loading branch information
kannanjgithub authored Nov 14, 2024
1 parent 468b29c commit 2636d5d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api/src/main/java/io/grpc/NameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,15 @@ public abstract static class Listener2 implements Listener {
@Override
@Deprecated
@InlineMe(
replacement = "this.onResult2(ResolutionResult.newBuilder().setAddressesOrError("
replacement = "this.onResult(ResolutionResult.newBuilder().setAddressesOrError("
+ "StatusOr.fromValue(servers)).setAttributes(attributes).build())",
imports = {"io.grpc.NameResolver.ResolutionResult", "io.grpc.StatusOr"})
public final void onAddresses(
List<EquivalentAddressGroup> servers, @ResolutionResultAttr Attributes attributes) {
// TODO(jihuncho) need to promote Listener2 if we want to use ConfigOrError
onResult2(
// Calling onResult and not onResult2 because onResult2 can only be called from a
// synchronization context.
onResult(
ResolutionResult.newBuilder().setAddressesOrError(
StatusOr.fromValue(servers)).setAttributes(attributes).build());
}
Expand Down

0 comments on commit 2636d5d

Please # to comment.