Skip to content

Commit dae078c

Browse files
authoredNov 5, 2024··
api: When forwarding from Listener onAddresses to Listener2 continue to use onResult (#11666)
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.
1 parent 664f1fc commit dae078c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎api/src/main/java/io/grpc/NameResolver.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,15 @@ public abstract static class Listener2 implements Listener {
219219
@Override
220220
@Deprecated
221221
@InlineMe(
222-
replacement = "this.onResult2(ResolutionResult.newBuilder().setAddressesOrError("
222+
replacement = "this.onResult(ResolutionResult.newBuilder().setAddressesOrError("
223223
+ "StatusOr.fromValue(servers)).setAttributes(attributes).build())",
224224
imports = {"io.grpc.NameResolver.ResolutionResult", "io.grpc.StatusOr"})
225225
public final void onAddresses(
226226
List<EquivalentAddressGroup> servers, @ResolutionResultAttr Attributes attributes) {
227227
// TODO(jihuncho) need to promote Listener2 if we want to use ConfigOrError
228-
onResult2(
228+
// Calling onResult and not onResult2 because onResult2 can only be called from a
229+
// synchronization context.
230+
onResult(
229231
ResolutionResult.newBuilder().setAddressesOrError(
230232
StatusOr.fromValue(servers)).setAttributes(attributes).build());
231233
}

0 commit comments

Comments
 (0)
Please sign in to comment.