Skip to content

Commit

Permalink
api: Deprecate the old way of handling resolved addresses in LoadBala…
Browse files Browse the repository at this point in the history
…ncer
  • Loading branch information
temawi committed Apr 7, 2023
1 parent 18e274d commit d122d3a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion api/src/main/java/io/grpc/LoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.InlineMe;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -126,7 +127,13 @@ public abstract class LoadBalancer {
*
* @param resolvedAddresses the resolved server addresses, attributes, and config.
* @since 1.21.0
* @deprecated Please override {@code acceptResolvedAddresses()} instead. Also note that
* {@code canHandleEmptyAddressListFromNameResolution()} is deprecated as well as
* {@code acceptResolvedAddresses()} should now indicate the acceptance of the addresses with
* its return value.
*/
@Deprecated
@InlineMe(replacement = "acceptResolvedAddresses(resolvedAddresses)")
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
if (recursionCount++ == 0) {
// Note that the information about the addresses actually being accepted will be lost
Expand All @@ -141,7 +148,9 @@ public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) {
* EquivalentAddressGroup} addresses should be considered equivalent but may be flattened into a
* single list if needed.
*
* <p>Implementations can choose to reject the given addresses by returning {@code false}.
* <p>Implementations can choose to reject the given addresses by returning {@code false}. Please
* note that an empty list of addresses could be provided and that the deprecated {@code
* canHandleEmptyAddressListFromNameResolution()} will be ignored when this method is overwritten.
*
* <p>Implementations should not modify the given {@code addresses}.
*
Expand Down Expand Up @@ -379,7 +388,16 @@ public void handleSubchannelState(
*
* <p>This method should always return a constant value. It's not specified when this will be
* called.
*
* <p>Note that this method is only called when the deprecated {@code handleResolvedAddresses()}
* is overwritten.
*
* @deprecated Instead of overwriting this and {@code handleResolvedAddresses()} please only
* overwrite {@code acceptResolvedAddresses()}. In that method you can indicate if the
* addresses provided by the name resolver are acceptable with the {@code boolean} return
* value.
*/
@Deprecated
public boolean canHandleEmptyAddressListFromNameResolution() {
return false;
}
Expand Down

0 comments on commit d122d3a

Please sign in to comment.