Skip to content

Commit cae37c8

Browse files
committed
Fixes grpc#12218
1 parent aa31fe7 commit cae37c8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public final void onAddresses(
238238
* Handles updates on resolved addresses and attributes. If
239239
* {@link ResolutionResult#getAddressesOrError()} is empty, {@link #onError(Status)} will be
240240
* called.
241+
* New implementations should prefer overriding onResult2. This method exists to facilitate
242+
* older implementations using {@link Listener} to migrate to {@link Listener2}.
241243
*
242244
* @param resolutionResult the resolved server addresses, attributes, and Service Config.
243245
* @since 1.21.0
@@ -247,6 +249,9 @@ public final void onAddresses(
247249
/**
248250
* Handles a name resolving error from the resolver. The listener is responsible for eventually
249251
* invoking {@link NameResolver#refresh()} to re-attempt resolution.
252+
* New implementations should prefer overriding onResult2 which will have the address
253+
* resolution error in {@link ResolutionResult}'s addressesOrError. This method exists to
254+
* facilitate older implementations using {@link Listener} to migrate to {@link Listener2}.
250255
*
251256
* @param error a non-OK status
252257
* @since 1.21.0
@@ -255,9 +260,13 @@ public final void onAddresses(
255260
public abstract void onError(Status error);
256261

257262
/**
258-
* Handles updates on resolved addresses and attributes.
263+
* Handles updates on resolved addresses and attributes. Must be called from
264+
* {@link SynchronizationContext}.
259265
*
260-
* @param resolutionResult the resolved server addresses, attributes, and Service Config.
266+
* @param resolutionResult the resolved server addresses or error in address resolution,
267+
* attributes, and Service Config or error
268+
* @return status indicating whether the resolutionResult was accepted by the listener,
269+
* typically the result from a load balancer.
261270
* @since 1.66
262271
*/
263272
public Status onResult2(ResolutionResult resolutionResult) {

0 commit comments

Comments
 (0)