File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed
api/src/main/java/io/grpc
core/src/main/java/io/grpc/internal
netty/src/main/java/io/grpc/netty Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -878,13 +878,14 @@ public String getServiceAuthority() {
878878
879879 @ Override
880880 public void start (Listener2 listener ) {
881- listener .onResult2 (
882- ResolutionResult .newBuilder ()
883- .setAddressesOrError (
884- StatusOr .fromValue (
885- Collections .singletonList (new EquivalentAddressGroup (address ))))
886- .setAttributes (Attributes .EMPTY )
887- .build ());
881+ args .getSynchronizationContext ().execute (() ->
882+ listener .onResult2 (
883+ ResolutionResult .newBuilder ()
884+ .setAddressesOrError (
885+ StatusOr .fromValue (
886+ Collections .singletonList (new EquivalentAddressGroup (address ))))
887+ .setAttributes (Attributes .EMPTY )
888+ .build ()));
888889 }
889890
890891 @ Override
Original file line number Diff line number Diff line change 3030final class UdsNameResolver extends NameResolver {
3131 private NameResolver .Listener2 listener ;
3232 private final String authority ;
33+ private final Args args ;
3334
3435 UdsNameResolver (String authority , String targetPath , Args args ) {
3536 checkArgument (authority == null , "non-null authority not supported" );
3637 this .authority = targetPath ;
38+ this .args = args ;
3739 }
3840
3941 @ Override
@@ -58,7 +60,8 @@ private void resolve() {
5860 List <EquivalentAddressGroup > servers = new ArrayList <>(1 );
5961 servers .add (new EquivalentAddressGroup (new DomainSocketAddress (authority )));
6062 resolutionResultBuilder .setAddressesOrError (StatusOr .fromValue (servers ));
61- listener .onResult2 (resolutionResultBuilder .build ());
63+ args .getSynchronizationContext ().execute (() ->
64+ listener .onResult2 (resolutionResultBuilder .build ()));
6265 }
6366
6467 @ Override
You can’t perform that action at this time.
0 commit comments