Cleanup some of the warnings across the code base (#9445)

No logic changes, just cleans up warnings to make spotting real problems easier.

Remove "public" declarations on interfaces
Remove duplicate semicolons (Java lines ending in ";;")
Remove unneeded import
Change non-javadoc comment to not start with "/**"
Remove unneeded explicit type declarations from generics
Fix broken javadoc links
This commit is contained in:
Larry Safran 2022-08-15 11:06:31 -07:00 committed by GitHub
parent 03430c786a
commit 01d5bd47cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 162 additions and 152 deletions

View File

@ -20,7 +20,6 @@ import io.grpc.ExperimentalApi;
import io.grpc.alts.internal.AltsInternalContext; import io.grpc.alts.internal.AltsInternalContext;
import io.grpc.alts.internal.HandshakerResult; import io.grpc.alts.internal.HandshakerResult;
import io.grpc.alts.internal.Identity; import io.grpc.alts.internal.Identity;
import io.grpc.alts.internal.SecurityLevel;
/** {@code AltsContext} contains security-related information on the ALTS channel. */ /** {@code AltsContext} contains security-related information on the ALTS channel. */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/7864") @ExperimentalApi("https://github.com/grpc/grpc-java/issues/7864")

View File

@ -64,12 +64,18 @@ class AltsHandshakerStub {
if (!responseQueue.isEmpty()) { if (!responseQueue.isEmpty()) {
throw new IOException("Received an unexpected response."); throw new IOException("Received an unexpected response.");
} }
writer.onNext(req); writer.onNext(req);
Optional<HandshakerResp> result = responseQueue.take(); Optional<HandshakerResp> result = responseQueue.take();
if (!result.isPresent()) { if (result.isPresent()) {
maybeThrowIoException(); return result.get();
}
if (exceptionMessage.get() != null) {
throw new IOException(exceptionMessage.get());
} else {
throw new IOException("No handshaker response received");
} }
return result.get();
} }
/** Create a new writer if the writer is null. */ /** Create a new writer if the writer is null. */

View File

@ -86,7 +86,7 @@ public interface TsiHandshaker {
* *
* @return the extracted peer. * @return the extracted peer.
*/ */
public Object extractPeerObject() throws GeneralSecurityException; Object extractPeerObject() throws GeneralSecurityException;
/** /**
* Creates a frame protector from a completed handshake. No other methods may be called after the * Creates a frame protector from a completed handshake. No other methods may be called after the

View File

@ -19,6 +19,7 @@ package io.grpc;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import io.grpc.Metadata.AsciiMarshaller; import io.grpc.Metadata.AsciiMarshaller;
import io.grpc.Metadata.BinaryStreamMarshaller; import io.grpc.Metadata.BinaryStreamMarshaller;
import java.io.InputStream;
import java.nio.charset.Charset; import java.nio.charset.Charset;
/** /**
@ -100,7 +101,7 @@ public final class InternalMetadata {
/** /**
* Creates a holder for a pre-parsed value read by the transport. * Creates a holder for a pre-parsed value read by the transport.
* *
* @param marshaller The {@link Metadata#BinaryStreamMarshaller} associated with this value. * @param marshaller The {@link Metadata.BinaryStreamMarshaller} associated with this value.
* @param value The value to store. * @param value The value to store.
* @return an object holding the pre-parsed value for this key. * @return an object holding the pre-parsed value for this key.
*/ */

View File

@ -211,8 +211,8 @@ public final class Metadata {
return size * 2; return size * 2;
} }
/** checks when {@link #namesAndValues} is null or has no elements. */
private boolean isEmpty() { private boolean isEmpty() {
/** checks when {@link #namesAndValues} is null or has no elements */
return size == 0; return size == 0;
} }

View File

@ -188,7 +188,7 @@ final class CensusStatsModule {
@Nullable @Nullable
private static final AtomicLongFieldUpdater<ClientTracer> inboundUncompressedSizeUpdater; private static final AtomicLongFieldUpdater<ClientTracer> inboundUncompressedSizeUpdater;
/** /*
* When using Atomic*FieldUpdater, some Samsung Android 5.0.x devices encounter a bug in their * When using Atomic*FieldUpdater, some Samsung Android 5.0.x devices encounter a bug in their
* JDK reflection API that triggers a NoSuchFieldException. When this occurs, we fallback to * JDK reflection API that triggers a NoSuchFieldException. When this occurs, we fallback to
* (potentially racy) direct updates of the volatile variables. * (potentially racy) direct updates of the volatile variables.
@ -268,7 +268,7 @@ final class CensusStatsModule {
} }
@Override @Override
@SuppressWarnings("NonAtomicVolatileUpdate") @SuppressWarnings({"NonAtomicVolatileUpdate", "NonAtomicOperationOnVolatileField"})
public void outboundWireSize(long bytes) { public void outboundWireSize(long bytes) {
if (outboundWireSizeUpdater != null) { if (outboundWireSizeUpdater != null) {
outboundWireSizeUpdater.getAndAdd(this, bytes); outboundWireSizeUpdater.getAndAdd(this, bytes);
@ -562,7 +562,7 @@ final class CensusStatsModule {
@Nullable @Nullable
private static final AtomicLongFieldUpdater<ServerTracer> inboundUncompressedSizeUpdater; private static final AtomicLongFieldUpdater<ServerTracer> inboundUncompressedSizeUpdater;
/** /*
* When using Atomic*FieldUpdater, some Samsung Android 5.0.x devices encounter a bug in their * When using Atomic*FieldUpdater, some Samsung Android 5.0.x devices encounter a bug in their
* JDK reflection API that triggers a NoSuchFieldException. When this occurs, we fallback to * JDK reflection API that triggers a NoSuchFieldException. When this occurs, we fallback to
* (potentially racy) direct updates of the volatile variables. * (potentially racy) direct updates of the volatile variables.

View File

@ -65,7 +65,7 @@ final class CensusTracingModule {
@Nullable private static final AtomicIntegerFieldUpdater<ServerTracer> streamClosedUpdater; @Nullable private static final AtomicIntegerFieldUpdater<ServerTracer> streamClosedUpdater;
/** /*
* When using Atomic*FieldUpdater, some Samsung Android 5.0.x devices encounter a bug in their JDK * When using Atomic*FieldUpdater, some Samsung Android 5.0.x devices encounter a bug in their JDK
* reflection API that triggers a NoSuchFieldException. When this occurs, we fallback to * reflection API that triggers a NoSuchFieldException. When this occurs, we fallback to
* (potentially racy) direct updates of the volatile variables. * (potentially racy) direct updates of the volatile variables.

View File

@ -20,7 +20,7 @@ package io.grpc.internal;
* Determines how long to wait before doing some action (typically a retry, or a reconnect). * Determines how long to wait before doing some action (typically a retry, or a reconnect).
*/ */
public interface BackoffPolicy { public interface BackoffPolicy {
public interface Provider { interface Provider {
BackoffPolicy get(); BackoffPolicy get();
} }

View File

@ -121,6 +121,7 @@ public class DelayedClientCall<ReqT, RespT> extends ClientCall<ReqT, RespT> {
buf.append(seconds); buf.append(seconds);
buf.append(String.format(Locale.US, ".%09d", nanos)); buf.append(String.format(Locale.US, ".%09d", nanos));
buf.append("s. "); buf.append("s. ");
/** Cancels the call if deadline exceeded prior to the real call being set. */ /** Cancels the call if deadline exceeded prior to the real call being set. */
class DeadlineExceededRunnable implements Runnable { class DeadlineExceededRunnable implements Runnable {
@Override @Override

View File

@ -50,7 +50,7 @@ public interface InternalServer {
void shutdown(); void shutdown();
/** /**
* Returns the first listening socket address. May change after {@link start(ServerListener)} is * Returns the first listening socket address. May change after {@link #start(ServerListener)} is
* called. * called.
*/ */
SocketAddress getListenSocketAddress(); SocketAddress getListenSocketAddress();
@ -61,7 +61,7 @@ public interface InternalServer {
@Nullable InternalInstrumented<SocketStats> getListenSocketStats(); @Nullable InternalInstrumented<SocketStats> getListenSocketStats();
/** /**
* Returns a list of listening socket addresses. May change after {@link start(ServerListener)} * Returns a list of listening socket addresses. May change after {@link #start(ServerListener)}
* is called. * is called.
*/ */
List<? extends SocketAddress> getListenSocketAddresses(); List<? extends SocketAddress> getListenSocketAddresses();

View File

@ -18,6 +18,7 @@ package io.grpc.internal;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancerProvider; import io.grpc.LoadBalancerProvider;
import io.grpc.NameResolver;
import io.grpc.NameResolver.ConfigOrError; import io.grpc.NameResolver.ConfigOrError;
import java.util.Map; import java.util.Map;

View File

@ -59,6 +59,6 @@ public interface StreamListener {
* messages until the producer returns null, at which point the producer may be discarded. * messages until the producer returns null, at which point the producer may be discarded.
*/ */
@Nullable @Nullable
public InputStream next(); InputStream next();
} }
} }

View File

@ -246,7 +246,8 @@ public final class AdvancedTlsX509KeyManager extends X509ExtendedKeyManager {
* Mainly used to avoid throwing IO Exceptions in java.io.Closeable. * Mainly used to avoid throwing IO Exceptions in java.io.Closeable.
*/ */
public interface Closeable extends java.io.Closeable { public interface Closeable extends java.io.Closeable {
@Override public void close(); @Override
void close();
} }
} }

View File

@ -295,7 +295,8 @@ public final class AdvancedTlsX509TrustManager extends X509ExtendedTrustManager
// Mainly used to avoid throwing IO Exceptions in java.io.Closeable. // Mainly used to avoid throwing IO Exceptions in java.io.Closeable.
public interface Closeable extends java.io.Closeable { public interface Closeable extends java.io.Closeable {
@Override public void close(); @Override
void close();
} }
public static Builder newBuilder() { public static Builder newBuilder() {

View File

@ -236,7 +236,7 @@ public class ServiceConfigErrorHandlingTest {
public void emptyAddresses_validConfig_firstResolution_lbNeedsAddress() throws Exception { public void emptyAddresses_validConfig_firstResolution_lbNeedsAddress() throws Exception {
FakeNameResolverFactory nameResolverFactory = FakeNameResolverFactory nameResolverFactory =
new FakeNameResolverFactory.Builder(expectedUri) new FakeNameResolverFactory.Builder(expectedUri)
.setServers(Collections.<EquivalentAddressGroup>emptyList()) .setServers(Collections.emptyList())
.build(); .build();
channelBuilder.nameResolverFactory(nameResolverFactory); channelBuilder.nameResolverFactory(nameResolverFactory);
@ -299,7 +299,7 @@ public class ServiceConfigErrorHandlingTest {
public void emptyAddresses_validConfig_lbDoesNotNeedAddress() throws Exception { public void emptyAddresses_validConfig_lbDoesNotNeedAddress() throws Exception {
FakeNameResolverFactory nameResolverFactory = FakeNameResolverFactory nameResolverFactory =
new FakeNameResolverFactory.Builder(expectedUri) new FakeNameResolverFactory.Builder(expectedUri)
.setServers(Collections.<EquivalentAddressGroup>emptyList()) .setServers(Collections.emptyList())
.build(); .build();
channelBuilder.nameResolverFactory(nameResolverFactory); channelBuilder.nameResolverFactory(nameResolverFactory);
when(mockLoadBalancer.canHandleEmptyAddressListFromNameResolution()).thenReturn(true); when(mockLoadBalancer.canHandleEmptyAddressListFromNameResolution()).thenReturn(true);
@ -316,7 +316,7 @@ public class ServiceConfigErrorHandlingTest {
ResolvedAddresses resolvedAddresses = resultCaptor.getValue(); ResolvedAddresses resolvedAddresses = resultCaptor.getValue();
assertThat(resolvedAddresses.getAddresses()).isEmpty(); assertThat(resolvedAddresses.getAddresses()).isEmpty();
assertThat(resolvedAddresses.getLoadBalancingPolicyConfig()).isEqualTo("val");; assertThat(resolvedAddresses.getLoadBalancingPolicyConfig()).isEqualTo("val");
verify(mockLoadBalancer, never()).handleNameResolutionError(any(Status.class)); verify(mockLoadBalancer, never()).handleNameResolutionError(any(Status.class));
assertThat(channel.getState(false)).isNotEqualTo(ConnectivityState.TRANSIENT_FAILURE); assertThat(channel.getState(false)).isNotEqualTo(ConnectivityState.TRANSIENT_FAILURE);

View File

@ -223,7 +223,7 @@ public class GcpObservabilityTest {
InternalLoggingChannelInterceptor.Factory channelInterceptorFactory = InternalLoggingChannelInterceptor.Factory channelInterceptorFactory =
mock(InternalLoggingChannelInterceptor.Factory.class); mock(InternalLoggingChannelInterceptor.Factory.class);
InternalLoggingServerInterceptor.Factory serverInterceptorFactory = InternalLoggingServerInterceptor.Factory serverInterceptorFactory =
mock(InternalLoggingServerInterceptor.Factory.class);; mock(InternalLoggingServerInterceptor.Factory.class);
try (GcpObservability unused = try (GcpObservability unused =
GcpObservability.grpcInit( GcpObservability.grpcInit(

View File

@ -238,7 +238,7 @@ abstract class AbstractNettyHandler extends GrpcHttp2ConnectionHandler {
/** Controls whether PINGs like those for BDP are permitted to be sent at the current time. */ /** Controls whether PINGs like those for BDP are permitted to be sent at the current time. */
public interface PingLimiter { public interface PingLimiter {
public boolean isPingAllowed(); boolean isPingAllowed();
} }
private static final class AllowPingLimiter implements PingLimiter { private static final class AllowPingLimiter implements PingLimiter {

View File

@ -251,7 +251,7 @@ class NettyClientTransport implements ConnectionClientTransport {
ChannelHandler bufferingHandler = new WriteBufferingAndExceptionHandler(negotiationHandler); ChannelHandler bufferingHandler = new WriteBufferingAndExceptionHandler(negotiationHandler);
/** /*
* We don't use a ChannelInitializer in the client bootstrap because its "initChannel" method * We don't use a ChannelInitializer in the client bootstrap because its "initChannel" method
* is executed in the event loop and we need this handler to be in the pipeline immediately so * is executed in the event loop and we need this handler to be in the pipeline immediately so
* that it may begin buffering writes. * that it may begin buffering writes.

View File

@ -184,7 +184,7 @@ final class WriteBufferingAndExceptionHandler extends ChannelDuplexHandler {
*/ */
@Override @Override
public void flush(ChannelHandlerContext ctx) { public void flush(ChannelHandlerContext ctx) {
/** /*
* Swallowing any flushes is not only an optimization but also required * Swallowing any flushes is not only an optimization but also required
* for the SslHandler to work correctly. If the SslHandler receives multiple * for the SslHandler to work correctly. If the SslHandler receives multiple
* flushes while the handshake is still ongoing, then the handshake "randomly" * flushes while the handshake is still ongoing, then the handshake "randomly"

View File

@ -822,7 +822,7 @@ final class XdsNameResolver extends NameResolver {
existingClusters == null ? clusters : Sets.difference(clusters, existingClusters); existingClusters == null ? clusters : Sets.difference(clusters, existingClusters);
Set<String> deletedClusters = Set<String> deletedClusters =
existingClusters == null existingClusters == null
? Collections.<String>emptySet() : Sets.difference(existingClusters, clusters); ? Collections.emptySet() : Sets.difference(existingClusters, clusters);
existingClusters = clusters; existingClusters = clusters;
for (String cluster : addedClusters) { for (String cluster : addedClusters) {
if (clusterRefs.containsKey(cluster)) { if (clusterRefs.containsKey(cluster)) {
@ -982,7 +982,7 @@ final class XdsNameResolver extends NameResolver {
final Map<String, FilterConfig> virtualHostOverrideConfig; final Map<String, FilterConfig> virtualHostOverrideConfig;
private static RoutingConfig empty = new RoutingConfig( private static RoutingConfig empty = new RoutingConfig(
0L, Collections.<Route>emptyList(), null, Collections.<String, FilterConfig>emptyMap()); 0, Collections.emptyList(), null, Collections.emptyMap());
private RoutingConfig( private RoutingConfig(
long fallbackTimeoutNano, List<Route> routes, @Nullable List<NamedFilterConfig> filterChain, long fallbackTimeoutNano, List<Route> routes, @Nullable List<NamedFilterConfig> filterChain,

View File

@ -19,5 +19,5 @@ package io.grpc.xds.internal.sds;
public interface Closeable extends java.io.Closeable { public interface Closeable extends java.io.Closeable {
@Override @Override
public void close(); void close();
} }

View File

@ -274,7 +274,7 @@ public class XdsNameResolverTest {
.authorities( .authorities(
ImmutableMap.of(targetAuthority, AuthorityInfo.create( ImmutableMap.of(targetAuthority, AuthorityInfo.create(
"xdstp://" + targetAuthority + "/envoy.config.listener.v3.Listener/%s?foo=1&bar=2", "xdstp://" + targetAuthority + "/envoy.config.listener.v3.Listener/%s?foo=1&bar=2",
ImmutableList.<ServerInfo>of(ServerInfo.create( ImmutableList.of(ServerInfo.create(
"td.googleapis.com", InsecureChannelCredentials.create(), true))))) "td.googleapis.com", InsecureChannelCredentials.create(), true)))))
.build(); .build();
expectedLdsResourceName = "xdstp://xds.authority.com/envoy.config.listener.v3.Listener/" expectedLdsResourceName = "xdstp://xds.authority.com/envoy.config.listener.v3.Listener/"
@ -299,12 +299,12 @@ public class XdsNameResolverTest {
public void resolving_ldsResourceUpdateRdsName() { public void resolving_ldsResourceUpdateRdsName() {
Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(20L), null), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
resolver.start(mockListener); resolver.start(mockListener);
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
@ -313,7 +313,7 @@ public class XdsNameResolverTest {
VirtualHost virtualHost = VirtualHost virtualHost =
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
Collections.singletonList(route1), Collections.singletonList(route1),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost)); xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
assertServiceConfigForLoadBalancingConfig( assertServiceConfigForLoadBalancingConfig(
@ -329,7 +329,7 @@ public class XdsNameResolverTest {
virtualHost = virtualHost =
VirtualHost.create("virtualhost-alter", Collections.singletonList(AUTHORITY), VirtualHost.create("virtualhost-alter", Collections.singletonList(AUTHORITY),
Collections.singletonList(route2), Collections.singletonList(route2),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
xdsClient.deliverRdsUpdate(alternativeRdsResource, Collections.singletonList(virtualHost)); xdsClient.deliverRdsUpdate(alternativeRdsResource, Collections.singletonList(virtualHost));
// Two new service config updates triggered: // Two new service config updates triggered:
// - with load balancing config being able to select cluster1 and cluster2 // - with load balancing config being able to select cluster1 and cluster2
@ -357,8 +357,8 @@ public class XdsNameResolverTest {
public void resolving_ldsResourceRevokedAndAddedBack() { public void resolving_ldsResourceRevokedAndAddedBack() {
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
resolver.start(mockListener); resolver.start(mockListener);
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
@ -367,7 +367,7 @@ public class XdsNameResolverTest {
VirtualHost virtualHost = VirtualHost virtualHost =
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
Collections.singletonList(route), Collections.singletonList(route),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost)); xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
assertServiceConfigForLoadBalancingConfig( assertServiceConfigForLoadBalancingConfig(
@ -396,8 +396,8 @@ public class XdsNameResolverTest {
public void resolving_rdsResourceRevokedAndAddedBack() { public void resolving_rdsResourceRevokedAndAddedBack() {
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
resolver.start(mockListener); resolver.start(mockListener);
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
@ -406,7 +406,7 @@ public class XdsNameResolverTest {
VirtualHost virtualHost = VirtualHost virtualHost =
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
Collections.singletonList(route), Collections.singletonList(route),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost)); xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
assertServiceConfigForLoadBalancingConfig( assertServiceConfigForLoadBalancingConfig(
@ -473,12 +473,12 @@ public class XdsNameResolverTest {
public void resolving_matchingVirtualHostNotFound_matchingOverrideAuthority() { public void resolving_matchingVirtualHostNotFound_matchingOverrideAuthority() {
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost virtualHost = VirtualHost virtualHost =
VirtualHost.create("virtualhost", Collections.singletonList("random"), VirtualHost.create("virtualhost", Collections.singletonList("random"),
Collections.singletonList(route), Collections.singletonList(route),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
resolver = new XdsNameResolver(null, AUTHORITY, "random", resolver = new XdsNameResolver(null, AUTHORITY, "random",
serviceConfigParser, syncContext, scheduler, serviceConfigParser, syncContext, scheduler,
@ -496,12 +496,12 @@ public class XdsNameResolverTest {
public void resolving_matchingVirtualHostNotFound_notMatchingOverrideAuthority() { public void resolving_matchingVirtualHostNotFound_notMatchingOverrideAuthority() {
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost virtualHost = VirtualHost virtualHost =
VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY),
Collections.singletonList(route), Collections.singletonList(route),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
resolver = new XdsNameResolver(null, AUTHORITY, "random", resolver = new XdsNameResolver(null, AUTHORITY, "random",
serviceConfigParser, syncContext, scheduler, serviceConfigParser, syncContext, scheduler,
@ -543,19 +543,19 @@ public class XdsNameResolverTest {
private List<VirtualHost> buildUnmatchedVirtualHosts() { private List<VirtualHost> buildUnmatchedVirtualHosts() {
Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), null), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
return Arrays.asList( return Arrays.asList(
VirtualHost.create("virtualhost-foo", Collections.singletonList("hello.googleapis.com"), VirtualHost.create("virtualhost-foo", Collections.singletonList("hello.googleapis.com"),
Collections.singletonList(route1), Collections.singletonList(route1),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
VirtualHost.create("virtualhost-bar", Collections.singletonList("hi.googleapis.com"), VirtualHost.create("virtualhost-bar", Collections.singletonList("hi.googleapis.com"),
Collections.singletonList(route2), Collections.singletonList(route2),
ImmutableMap.<String, FilterConfig>of())); ImmutableMap.of()));
} }
@Test @Test
@ -564,11 +564,11 @@ public class XdsNameResolverTest {
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), null, null), // per-route timeout unset cluster1, Collections.emptyList(), null, null), // per-route timeout unset
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost virtualHost = VirtualHost.create("does not matter", VirtualHost virtualHost = VirtualHost.create("does not matter",
Collections.singletonList(AUTHORITY), Collections.singletonList(route), Collections.singletonList(AUTHORITY), Collections.singletonList(route),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
xdsClient.deliverLdsUpdate(0L, Collections.singletonList(virtualHost)); xdsClient.deliverLdsUpdate(0L, Collections.singletonList(virtualHost));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
@ -582,11 +582,11 @@ public class XdsNameResolverTest {
FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient();
Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), null, null), // per-route timeout unset cluster1, Collections.emptyList(), null, null), // per-route timeout unset
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost virtualHost = VirtualHost.create("does not matter", VirtualHost virtualHost = VirtualHost.create("does not matter",
Collections.singletonList(AUTHORITY), Collections.singletonList(route), Collections.singletonList(AUTHORITY), Collections.singletonList(route),
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
xdsClient.deliverLdsUpdate(TimeUnit.SECONDS.toNanos(5L), xdsClient.deliverLdsUpdate(TimeUnit.SECONDS.toNanos(5L),
Collections.singletonList(virtualHost)); Collections.singletonList(virtualHost));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
@ -612,10 +612,10 @@ public class XdsNameResolverTest {
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, cluster1,
Collections.<HashPolicy>emptyList(), Collections.emptyList(),
null, null,
retryPolicy), retryPolicy),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
@ -668,12 +668,12 @@ public class XdsNameResolverTest {
Arrays.asList( Arrays.asList(
Route.forNonForwardingAction( Route.forNonForwardingAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster(cluster2, Collections.<HashPolicy>emptyList(), RouteAction.forCluster(cluster2, Collections.emptyList(),
TimeUnit.SECONDS.toNanos(15L), null), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
assertThat(result.getAddresses()).isEmpty(); assertThat(result.getAddresses()).isEmpty();
@ -709,7 +709,7 @@ public class XdsNameResolverTest {
HashPolicy.forHeader(false, "custom-key", null, null)), HashPolicy.forHeader(false, "custom-key", null, null)),
null, null,
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
InternalConfigSelector configSelector = InternalConfigSelector configSelector =
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY); resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
@ -743,7 +743,7 @@ public class XdsNameResolverTest {
HashPolicy.forHeader(false, "custom-key", Pattern.compile("value"), "val")), HashPolicy.forHeader(false, "custom-key", Pattern.compile("value"), "val")),
null, null,
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
InternalConfigSelector configSelector = InternalConfigSelector configSelector =
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY); resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
@ -782,7 +782,7 @@ public class XdsNameResolverTest {
Collections.singletonList(HashPolicy.forChannelId(false)), Collections.singletonList(HashPolicy.forChannelId(false)),
null, null,
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
InternalConfigSelector configSelector = InternalConfigSelector configSelector =
resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY); resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY);
@ -795,7 +795,7 @@ public class XdsNameResolverTest {
// Second call, with no custom header. // Second call, with no custom header.
startNewCall(TestMethodDescriptors.voidMethod(), configSelector, startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), Collections.emptyMap(),
CallOptions.DEFAULT); CallOptions.DEFAULT);
long hash2 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY); long hash2 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY);
@ -817,14 +817,14 @@ public class XdsNameResolverTest {
Collections.singletonList(HashPolicy.forChannelId(false)), Collections.singletonList(HashPolicy.forChannelId(false)),
null, null,
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
configSelector = resolutionResultCaptor.getValue().getAttributes().get( configSelector = resolutionResultCaptor.getValue().getAttributes().get(
InternalConfigSelector.KEY); InternalConfigSelector.KEY);
// Third call, with no custom header. // Third call, with no custom header.
startNewCall(TestMethodDescriptors.voidMethod(), configSelector, startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), Collections.emptyMap(),
CallOptions.DEFAULT); CallOptions.DEFAULT);
long hash3 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY); long hash3 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY);
@ -846,15 +846,15 @@ public class XdsNameResolverTest {
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
"another-cluster", Collections.<HashPolicy>emptyList(), "another-cluster", Collections.emptyList(),
TimeUnit.SECONDS.toNanos(20L), null), TimeUnit.SECONDS.toNanos(20L), null),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
// Updated service config still contains cluster1 while it is removed resource. New calls no // Updated service config still contains cluster1 while it is removed resource. New calls no
@ -886,15 +886,15 @@ public class XdsNameResolverTest {
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
"another-cluster", Collections.<HashPolicy>emptyList(), "another-cluster", Collections.emptyList(),
TimeUnit.SECONDS.toNanos(20L), null), TimeUnit.SECONDS.toNanos(20L), null),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
// Two consecutive service config updates: one for removing clcuster1, // Two consecutive service config updates: one for removing clcuster1,
// one for adding "another=cluster". // one for adding "another=cluster".
verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture()); verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture());
@ -922,15 +922,15 @@ public class XdsNameResolverTest {
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
"another-cluster", Collections.<HashPolicy>emptyList(), "another-cluster", Collections.emptyList(),
TimeUnit.SECONDS.toNanos(20L), null), TimeUnit.SECONDS.toNanos(20L), null),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), cluster2, Collections.emptyList(),
TimeUnit.SECONDS.toNanos(15L), null), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
@ -943,15 +943,15 @@ public class XdsNameResolverTest {
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
"another-cluster", Collections.<HashPolicy>emptyList(), "another-cluster", Collections.emptyList(),
TimeUnit.SECONDS.toNanos(15L), null), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), cluster2, Collections.emptyList(),
TimeUnit.SECONDS.toNanos(15L), null), TimeUnit.SECONDS.toNanos(15L), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verifyNoMoreInteractions(mockListener); // no cluster added/deleted verifyNoMoreInteractions(mockListener); // no cluster added/deleted
assertCallSelectClusterResult(call1, configSelector, "another-cluster", 15.0); assertCallSelectClusterResult(call1, configSelector, "another-cluster", 15.0);
} }
@ -966,23 +966,23 @@ public class XdsNameResolverTest {
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
xdsClient.deliverLdsUpdate( xdsClient.deliverLdsUpdate(
Arrays.asList( Arrays.asList(
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
testCall.deliverErrorStatus(); testCall.deliverErrorStatus();
verifyNoMoreInteractions(mockListener); verifyNoMoreInteractions(mockListener);
} }
@ -999,13 +999,13 @@ public class XdsNameResolverTest {
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forWeightedClusters( RouteAction.forWeightedClusters(
Arrays.asList( Arrays.asList(
ClusterWeight.create(cluster1, 20, ImmutableMap.<String, FilterConfig>of()), ClusterWeight.create(cluster1, 20, ImmutableMap.of()),
ClusterWeight.create( ClusterWeight.create(
cluster2, 80, ImmutableMap.<String, FilterConfig>of())), cluster2, 80, ImmutableMap.of())),
Collections.<HashPolicy>emptyList(), Collections.emptyList(),
TimeUnit.SECONDS.toNanos(20L), TimeUnit.SECONDS.toNanos(20L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
assertThat(result.getAddresses()).isEmpty(); assertThat(result.getAddresses()).isEmpty();
@ -1031,10 +1031,10 @@ public class XdsNameResolverTest {
"rls-plugin-foo", "rls-plugin-foo",
RlsPluginConfig.create( RlsPluginConfig.create(
ImmutableMap.of("lookupService", "rls-cbt.googleapis.com"))), ImmutableMap.of("lookupService", "rls-cbt.googleapis.com"))),
Collections.<HashPolicy>emptyList(), Collections.emptyList(),
TimeUnit.SECONDS.toNanos(20L), TimeUnit.SECONDS.toNanos(20L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
assertThat(result.getAddresses()).isEmpty(); assertThat(result.getAddresses()).isEmpty();
@ -1078,11 +1078,11 @@ public class XdsNameResolverTest {
RlsPluginConfig.create( RlsPluginConfig.create(
// changed // changed
ImmutableMap.of("lookupService", "rls-cbt-2.googleapis.com"))), ImmutableMap.of("lookupService", "rls-cbt-2.googleapis.com"))),
Collections.<HashPolicy>emptyList(), Collections.emptyList(),
// changed // changed
TimeUnit.SECONDS.toNanos(30L), TimeUnit.SECONDS.toNanos(30L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture()); verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture());
ResolutionResult result2 = resolutionResultCaptor.getValue(); ResolutionResult result2 = resolutionResultCaptor.getValue();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -1136,7 +1136,7 @@ public class XdsNameResolverTest {
ClientInterceptor interceptor = result.getInterceptor(); ClientInterceptor interceptor = result.getInterceptor();
ClientCall<Void, Void> clientCall = interceptor.interceptCall( ClientCall<Void, Void> clientCall = interceptor.interceptCall(
call.methodDescriptor, CallOptions.DEFAULT, channel); call.methodDescriptor, CallOptions.DEFAULT, channel);
clientCall.start(new NoopClientCallListener<Void>(), new Metadata()); clientCall.start(new NoopClientCallListener<>(), new Metadata());
assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY)) assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY))
.isEqualTo("cluster:" + expectedCluster); .isEqualTo("cluster:" + expectedCluster);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -1164,7 +1164,7 @@ public class XdsNameResolverTest {
ClientInterceptor interceptor = result.getInterceptor(); ClientInterceptor interceptor = result.getInterceptor();
ClientCall<Void, Void> clientCall = interceptor.interceptCall( ClientCall<Void, Void> clientCall = interceptor.interceptCall(
call.methodDescriptor, CallOptions.DEFAULT, channel); call.methodDescriptor, CallOptions.DEFAULT, channel);
clientCall.start(new NoopClientCallListener<Void>(), new Metadata()); clientCall.start(new NoopClientCallListener<>(), new Metadata());
assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY)) assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY))
.isEqualTo("cluster_specifier_plugin:" + expectedPluginName); .isEqualTo("cluster_specifier_plugin:" + expectedPluginName);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -1186,15 +1186,15 @@ public class XdsNameResolverTest {
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster1, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()), ImmutableMap.of()),
Route.forAction( Route.forAction(
RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()),
RouteAction.forCluster( RouteAction.forCluster(
cluster2, Collections.<HashPolicy>emptyList(), TimeUnit.SECONDS.toNanos(15L), cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L),
null), null),
ImmutableMap.<String, FilterConfig>of()))); ImmutableMap.of())));
verify(mockListener).onResult(resolutionResultCaptor.capture()); verify(mockListener).onResult(resolutionResultCaptor.capture());
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
assertThat(result.getAddresses()).isEmpty(); assertThat(result.getAddresses()).isEmpty();
@ -1329,7 +1329,7 @@ public class XdsNameResolverTest {
4, ImmutableList.of(Code.UNAVAILABLE, Code.CANCELLED), Durations.fromMillis(100), 4, ImmutableList.of(Code.UNAVAILABLE, Code.CANCELLED), Durations.fromMillis(100),
Durations.fromMillis(200), null); Durations.fromMillis(200), null);
RetryPolicy retryPolicyWithEmptyStatusCodes = RetryPolicy.create( RetryPolicy retryPolicyWithEmptyStatusCodes = RetryPolicy.create(
4, ImmutableList.<Code>of(), Durations.fromMillis(100), Durations.fromMillis(200), null); 4, ImmutableList.of(), Durations.fromMillis(100), Durations.fromMillis(200), null);
// timeout only // timeout only
String expectedServiceConfigJson = "{\n" String expectedServiceConfigJson = "{\n"
@ -1451,13 +1451,13 @@ public class XdsNameResolverTest {
List<Route> routes = Collections.emptyList(); List<Route> routes = Collections.emptyList();
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com", VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
Arrays.asList("a.googleapis.com", "b.googleapis.com"), routes, Arrays.asList("a.googleapis.com", "b.googleapis.com"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com", VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
Collections.singletonList("*.googleapis.com"), routes, Collections.singletonList("*.googleapis.com"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com", VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com",
Collections.singletonList("*"), routes, Collections.singletonList("*"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3); List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3);
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname)) assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
.isEqualTo(vHost1); .isEqualTo(vHost1);
@ -1469,13 +1469,13 @@ public class XdsNameResolverTest {
List<Route> routes = Collections.emptyList(); List<Route> routes = Collections.emptyList();
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com", VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
Arrays.asList("*.googleapis.com", "b.googleapis.com"), routes, Arrays.asList("*.googleapis.com", "b.googleapis.com"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com", VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
Collections.singletonList("a.googleapis.*"), routes, Collections.singletonList("a.googleapis.*"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com", VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com",
Collections.singletonList("*"), routes, Collections.singletonList("*"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3); List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2, vHost3);
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname)) assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
.isEqualTo(vHost1); .isEqualTo(vHost1);
@ -1487,13 +1487,13 @@ public class XdsNameResolverTest {
List<Route> routes = Collections.emptyList(); List<Route> routes = Collections.emptyList();
VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com", VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com",
Collections.singletonList("*"), routes, Collections.singletonList("*"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com", VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com",
Collections.singletonList("b.googleapis.com"), routes, Collections.singletonList("b.googleapis.com"), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2); List<VirtualHost> virtualHosts = Arrays.asList(vHost1, vHost2);
assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname)) assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname))
.isEqualTo(vHost1);; .isEqualTo(vHost1);
} }
@Test @Test
@ -1513,7 +1513,7 @@ public class XdsNameResolverTest {
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
// no header abort key provided in metadata, rpc should succeed // no header abort key provided in metadata, rpc should succeed
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcSucceeded(observer); verifyRpcSucceeded(observer);
// header abort http status key provided, rpc should fail // header abort http status key provided, rpc should fail
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
@ -1582,7 +1582,7 @@ public class XdsNameResolverTest {
result = resolutionResultCaptor.getValue(); result = resolutionResultCaptor.getValue();
configSelector = result.getAttributes().get(InternalConfigSelector.KEY); configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), CallOptions.DEFAULT); Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcFailed( verifyRpcFailed(
observer, observer,
Status.UNAUTHENTICATED.withDescription( Status.UNAUTHENTICATED.withDescription(
@ -1600,7 +1600,7 @@ public class XdsNameResolverTest {
result = resolutionResultCaptor.getValue(); result = resolutionResultCaptor.getValue();
configSelector = result.getAttributes().get(InternalConfigSelector.KEY); configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), CallOptions.DEFAULT); Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcSucceeded(observer); verifyRpcSucceeded(observer);
} }
@ -1619,7 +1619,7 @@ public class XdsNameResolverTest {
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
// no header delay key provided in metadata, rpc should succeed immediately // no header delay key provided in metadata, rpc should succeed immediately
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcSucceeded(observer); verifyRpcSucceeded(observer);
// header delay key provided, rpc should be delayed // header delay key provided, rpc should be delayed
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
@ -1659,7 +1659,7 @@ public class XdsNameResolverTest {
result = resolutionResultCaptor.getValue(); result = resolutionResultCaptor.getValue();
configSelector = result.getAttributes().get(InternalConfigSelector.KEY); configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), CallOptions.DEFAULT); Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcDelayed(observer, 5000L); verifyRpcDelayed(observer, 5000L);
// fixed delay, fix rate = 40% // fixed delay, fix rate = 40%
@ -1672,7 +1672,7 @@ public class XdsNameResolverTest {
result = resolutionResultCaptor.getValue(); result = resolutionResultCaptor.getValue();
configSelector = result.getAttributes().get(InternalConfigSelector.KEY); configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), CallOptions.DEFAULT); Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcSucceeded(observer); verifyRpcSucceeded(observer);
} }
@ -1694,15 +1694,15 @@ public class XdsNameResolverTest {
// Send two calls, then the first call should delayed and the second call should not be delayed // Send two calls, then the first call should delayed and the second call should not be delayed
// because maxActiveFaults is exceeded. // because maxActiveFaults is exceeded.
ClientCall.Listener<Void> observer1 = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer1 = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
assertThat(testCall).isNull(); assertThat(testCall).isNull();
ClientCall.Listener<Void> observer2 = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer2 = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcSucceeded(observer2); verifyRpcSucceeded(observer2);
verifyRpcDelayed(observer1, 5000L); verifyRpcDelayed(observer1, 5000L);
// Once all calls are finished, new call should be delayed. // Once all calls are finished, new call should be delayed.
ClientCall.Listener<Void> observer3 = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer3 = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcDelayed(observer3, 5000L); verifyRpcDelayed(observer3, 5000L);
} }
@ -1728,7 +1728,7 @@ public class XdsNameResolverTest {
} }
}; };
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT.withDeadline( configSelector, Collections.emptyMap(), CallOptions.DEFAULT.withDeadline(
Deadline.after(4000, TimeUnit.NANOSECONDS, fakeTicker))); Deadline.after(4000, TimeUnit.NANOSECONDS, fakeTicker)));
assertThat(testCall).isNull(); assertThat(testCall).isNull();
verifyRpcDelayedThenAborted(observer, 4000L, Status.DEADLINE_EXCEEDED.withDescription( verifyRpcDelayedThenAborted(observer, 4000L, Status.DEADLINE_EXCEEDED.withDescription(
@ -1753,7 +1753,7 @@ public class XdsNameResolverTest {
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcDelayedThenAborted( verifyRpcDelayedThenAborted(
observer, 5000L, observer, 5000L,
Status.UNAUTHENTICATED.withDescription( Status.UNAUTHENTICATED.withDescription(
@ -1782,7 +1782,7 @@ public class XdsNameResolverTest {
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT); configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcFailed( verifyRpcFailed(
observer, Status.INTERNAL.withDescription("RPC terminated due to fault injection")); observer, Status.INTERNAL.withDescription("RPC terminated due to fault injection"));
@ -1797,7 +1797,7 @@ public class XdsNameResolverTest {
result = resolutionResultCaptor.getValue(); result = resolutionResultCaptor.getValue();
configSelector = result.getAttributes().get(InternalConfigSelector.KEY); configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), CallOptions.DEFAULT); Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcFailed( verifyRpcFailed(
observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection")); observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection"));
@ -1814,7 +1814,7 @@ public class XdsNameResolverTest {
result = resolutionResultCaptor.getValue(); result = resolutionResultCaptor.getValue();
configSelector = result.getAttributes().get(InternalConfigSelector.KEY); configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector,
Collections.<String, String>emptyMap(), CallOptions.DEFAULT); Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcFailed( verifyRpcFailed(
observer, Status.UNAVAILABLE.withDescription("RPC terminated due to fault injection")); observer, Status.UNAVAILABLE.withDescription("RPC terminated due to fault injection"));
} }
@ -1843,7 +1843,7 @@ public class XdsNameResolverTest {
ResolutionResult result = resolutionResultCaptor.getValue(); ResolutionResult result = resolutionResultCaptor.getValue();
InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY);
ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(), ClientCall.Listener<Void> observer = startNewCall(TestMethodDescriptors.voidMethod(),
configSelector, Collections.<String, String>emptyMap(), CallOptions.DEFAULT);; configSelector, Collections.emptyMap(), CallOptions.DEFAULT);
verifyRpcFailed( verifyRpcFailed(
observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection")); observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection"));
} }
@ -1904,7 +1904,7 @@ public class XdsNameResolverTest {
RouteMatch routeMatch1 = RouteMatch routeMatch1 =
RouteMatch.create( RouteMatch.create(
PathMatcher.fromPath("/FooService/barMethod", true), PathMatcher.fromPath("/FooService/barMethod", true),
Collections.<HeaderMatcher>emptyList(), null); Collections.emptyList(), null);
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/barMethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/barMethod", headers, random))
.isTrue(); .isTrue();
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/bazMethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/bazMethod", headers, random))
@ -1913,7 +1913,7 @@ public class XdsNameResolverTest {
RouteMatch routeMatch2 = RouteMatch routeMatch2 =
RouteMatch.create( RouteMatch.create(
PathMatcher.fromPrefix("/FooService/", true), PathMatcher.fromPrefix("/FooService/", true),
Collections.<HeaderMatcher>emptyList(), null); Collections.emptyList(), null);
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/barMethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/barMethod", headers, random))
.isTrue(); .isTrue();
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/bazMethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/bazMethod", headers, random))
@ -1924,7 +1924,7 @@ public class XdsNameResolverTest {
RouteMatch routeMatch3 = RouteMatch routeMatch3 =
RouteMatch.create( RouteMatch.create(
PathMatcher.fromRegEx(Pattern.compile(".*Foo.*")), PathMatcher.fromRegEx(Pattern.compile(".*Foo.*")),
Collections.<HeaderMatcher>emptyList(), null); Collections.emptyList(), null);
assertThat(XdsNameResolver.matchRoute(routeMatch3, "/FooService/barMethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch3, "/FooService/barMethod", headers, random))
.isTrue(); .isTrue();
} }
@ -1937,14 +1937,14 @@ public class XdsNameResolverTest {
RouteMatch routeMatch1 = RouteMatch routeMatch1 =
RouteMatch.create( RouteMatch.create(
PathMatcher.fromPath("/FooService/barMethod", false), PathMatcher.fromPath("/FooService/barMethod", false),
Collections.<HeaderMatcher>emptyList(), null); Collections.emptyList(), null);
assertThat(XdsNameResolver.matchRoute(routeMatch1, "/fooservice/barmethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch1, "/fooservice/barmethod", headers, random))
.isTrue(); .isTrue();
RouteMatch routeMatch2 = RouteMatch routeMatch2 =
RouteMatch.create( RouteMatch.create(
PathMatcher.fromPrefix("/FooService", false), PathMatcher.fromPrefix("/FooService", false),
Collections.<HeaderMatcher>emptyList(), null); Collections.emptyList(), null);
assertThat(XdsNameResolver.matchRoute(routeMatch2, "/fooservice/barmethod", headers, random)) assertThat(XdsNameResolver.matchRoute(routeMatch2, "/fooservice/barmethod", headers, random))
.isTrue(); .isTrue();
} }
@ -2122,7 +2122,7 @@ public class XdsNameResolverTest {
VirtualHost virtualHost = VirtualHost virtualHost =
VirtualHost.create( VirtualHost.create(
"virtual-host", Collections.singletonList(expectedLdsResourceName), routes, "virtual-host", Collections.singletonList(expectedLdsResourceName), routes,
ImmutableMap.<String, FilterConfig>of()); ImmutableMap.of());
ldsWatcher.onChanged(LdsUpdate.forApiListener(HttpConnectionManager.forVirtualHosts( ldsWatcher.onChanged(LdsUpdate.forApiListener(HttpConnectionManager.forVirtualHosts(
0L, Collections.singletonList(virtualHost), null))); 0L, Collections.singletonList(virtualHost), null)));
} }
@ -2140,28 +2140,28 @@ public class XdsNameResolverTest {
new NamedFilterConfig(FAULT_FILTER_INSTANCE_NAME, httpFilterFaultConfig), new NamedFilterConfig(FAULT_FILTER_INSTANCE_NAME, httpFilterFaultConfig),
new NamedFilterConfig(ROUTER_FILTER_INSTANCE_NAME, RouterFilter.ROUTER_CONFIG)); new NamedFilterConfig(ROUTER_FILTER_INSTANCE_NAME, RouterFilter.ROUTER_CONFIG));
ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null
? ImmutableMap.<String, FilterConfig>of() ? ImmutableMap.of()
: ImmutableMap.<String, FilterConfig>of( : ImmutableMap.of(
FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig); FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig);
ClusterWeight clusterWeight = ClusterWeight clusterWeight =
ClusterWeight.create( ClusterWeight.create(
cluster, 100, cluster, 100,
overrideConfig); overrideConfig);
overrideConfig = routeFaultConfig == null overrideConfig = routeFaultConfig == null
? ImmutableMap.<String, FilterConfig>of() ? ImmutableMap.of()
: ImmutableMap.<String, FilterConfig>of(FAULT_FILTER_INSTANCE_NAME, routeFaultConfig); : ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routeFaultConfig);
Route route = Route.forAction( Route route = Route.forAction(
RouteMatch.create( RouteMatch.create(
PathMatcher.fromPrefix("/", false), Collections.<HeaderMatcher>emptyList(), null), PathMatcher.fromPrefix("/", false), Collections.emptyList(), null),
RouteAction.forWeightedClusters( RouteAction.forWeightedClusters(
Collections.singletonList(clusterWeight), Collections.singletonList(clusterWeight),
Collections.<HashPolicy>emptyList(), Collections.emptyList(),
null, null,
null), null),
overrideConfig); overrideConfig);
overrideConfig = virtualHostFaultConfig == null overrideConfig = virtualHostFaultConfig == null
? ImmutableMap.<String, FilterConfig>of() ? ImmutableMap.of()
: ImmutableMap.<String, FilterConfig>of( : ImmutableMap.of(
FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig); FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig);
VirtualHost virtualHost = VirtualHost.create( VirtualHost virtualHost = VirtualHost.create(
"virtual-host", "virtual-host",
@ -2201,26 +2201,26 @@ public class XdsNameResolverTest {
return; return;
} }
ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null ImmutableMap<String, FilterConfig> overrideConfig = weightedClusterFaultConfig == null
? ImmutableMap.<String, FilterConfig>of() ? ImmutableMap.of()
: ImmutableMap.<String, FilterConfig>of( : ImmutableMap.of(
FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig); FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig);
ClusterWeight clusterWeight = ClusterWeight clusterWeight =
ClusterWeight.create(cluster1, 100, overrideConfig); ClusterWeight.create(cluster1, 100, overrideConfig);
overrideConfig = routFaultConfig == null overrideConfig = routFaultConfig == null
? ImmutableMap.<String, FilterConfig>of() ? ImmutableMap.of()
: ImmutableMap.<String, FilterConfig>of(FAULT_FILTER_INSTANCE_NAME, routFaultConfig); : ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routFaultConfig);
Route route = Route.forAction( Route route = Route.forAction(
RouteMatch.create( RouteMatch.create(
PathMatcher.fromPrefix("/", false), Collections.<HeaderMatcher>emptyList(), null), PathMatcher.fromPrefix("/", false), Collections.emptyList(), null),
RouteAction.forWeightedClusters( RouteAction.forWeightedClusters(
Collections.singletonList(clusterWeight), Collections.singletonList(clusterWeight),
Collections.<HashPolicy>emptyList(), Collections.emptyList(),
null, null,
null), null),
overrideConfig); overrideConfig);
overrideConfig = virtualHostFaultConfig == null overrideConfig = virtualHostFaultConfig == null
? ImmutableMap.<String, FilterConfig>of() ? ImmutableMap.of()
: ImmutableMap.<String, FilterConfig>of( : ImmutableMap.of(
FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig); FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig);
VirtualHost virtualHost = VirtualHost.create( VirtualHost virtualHost = VirtualHost.create(
"virtual-host", "virtual-host",