From 01d5bd47cb0bf19965d31abb05dc5bab84a028c8 Mon Sep 17 00:00:00 2001 From: Larry Safran <107004254+larry-safran@users.noreply.github.com> Date: Mon, 15 Aug 2022 11:06:31 -0700 Subject: [PATCH] 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 --- .../main/java/io/grpc/alts/AltsContext.java | 1 - .../alts/internal/AltsHandshakerStub.java | 12 +- .../io/grpc/alts/internal/TsiHandshaker.java | 2 +- .../main/java/io/grpc/InternalMetadata.java | 3 +- api/src/main/java/io/grpc/Metadata.java | 2 +- .../io/grpc/census/CensusStatsModule.java | 6 +- .../io/grpc/census/CensusTracingModule.java | 2 +- .../java/io/grpc/internal/BackoffPolicy.java | 2 +- .../io/grpc/internal/DelayedClientCall.java | 1 + .../java/io/grpc/internal/InternalServer.java | 4 +- .../PickFirstLoadBalancerProvider.java | 1 + .../java/io/grpc/internal/StreamListener.java | 2 +- .../grpc/util/AdvancedTlsX509KeyManager.java | 3 +- .../util/AdvancedTlsX509TrustManager.java | 3 +- .../ServiceConfigErrorHandlingTest.java | 6 +- .../observability/GcpObservabilityTest.java | 2 +- .../io/grpc/netty/AbstractNettyHandler.java | 2 +- .../io/grpc/netty/NettyClientTransport.java | 2 +- .../WriteBufferingAndExceptionHandler.java | 2 +- .../java/io/grpc/xds/XdsNameResolver.java | 4 +- .../io/grpc/xds/internal/sds/Closeable.java | 2 +- .../java/io/grpc/xds/XdsNameResolverTest.java | 250 +++++++++--------- 22 files changed, 162 insertions(+), 152 deletions(-) diff --git a/alts/src/main/java/io/grpc/alts/AltsContext.java b/alts/src/main/java/io/grpc/alts/AltsContext.java index f264ad112d..7680de4160 100644 --- a/alts/src/main/java/io/grpc/alts/AltsContext.java +++ b/alts/src/main/java/io/grpc/alts/AltsContext.java @@ -20,7 +20,6 @@ import io.grpc.ExperimentalApi; import io.grpc.alts.internal.AltsInternalContext; import io.grpc.alts.internal.HandshakerResult; import io.grpc.alts.internal.Identity; -import io.grpc.alts.internal.SecurityLevel; /** {@code AltsContext} contains security-related information on the ALTS channel. */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/7864") diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java index 61d9fd2f89..bb2ff9dbc4 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsHandshakerStub.java @@ -64,12 +64,18 @@ class AltsHandshakerStub { if (!responseQueue.isEmpty()) { throw new IOException("Received an unexpected response."); } + writer.onNext(req); Optional result = responseQueue.take(); - if (!result.isPresent()) { - maybeThrowIoException(); + if (result.isPresent()) { + 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. */ diff --git a/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java b/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java index 35b945770d..c6da647168 100644 --- a/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java +++ b/alts/src/main/java/io/grpc/alts/internal/TsiHandshaker.java @@ -86,7 +86,7 @@ public interface TsiHandshaker { * * @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 diff --git a/api/src/main/java/io/grpc/InternalMetadata.java b/api/src/main/java/io/grpc/InternalMetadata.java index 2823882952..cbf6b72aaf 100644 --- a/api/src/main/java/io/grpc/InternalMetadata.java +++ b/api/src/main/java/io/grpc/InternalMetadata.java @@ -19,6 +19,7 @@ package io.grpc; import com.google.common.io.BaseEncoding; import io.grpc.Metadata.AsciiMarshaller; import io.grpc.Metadata.BinaryStreamMarshaller; +import java.io.InputStream; 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. * - * @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. * @return an object holding the pre-parsed value for this key. */ diff --git a/api/src/main/java/io/grpc/Metadata.java b/api/src/main/java/io/grpc/Metadata.java index 9c2a2227f8..6311762601 100644 --- a/api/src/main/java/io/grpc/Metadata.java +++ b/api/src/main/java/io/grpc/Metadata.java @@ -211,8 +211,8 @@ public final class Metadata { return size * 2; } + /** checks when {@link #namesAndValues} is null or has no elements. */ private boolean isEmpty() { - /** checks when {@link #namesAndValues} is null or has no elements */ return size == 0; } diff --git a/census/src/main/java/io/grpc/census/CensusStatsModule.java b/census/src/main/java/io/grpc/census/CensusStatsModule.java index 366be55de6..1d016abc89 100644 --- a/census/src/main/java/io/grpc/census/CensusStatsModule.java +++ b/census/src/main/java/io/grpc/census/CensusStatsModule.java @@ -188,7 +188,7 @@ final class CensusStatsModule { @Nullable private static final AtomicLongFieldUpdater inboundUncompressedSizeUpdater; - /** + /* * 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 * (potentially racy) direct updates of the volatile variables. @@ -268,7 +268,7 @@ final class CensusStatsModule { } @Override - @SuppressWarnings("NonAtomicVolatileUpdate") + @SuppressWarnings({"NonAtomicVolatileUpdate", "NonAtomicOperationOnVolatileField"}) public void outboundWireSize(long bytes) { if (outboundWireSizeUpdater != null) { outboundWireSizeUpdater.getAndAdd(this, bytes); @@ -562,7 +562,7 @@ final class CensusStatsModule { @Nullable private static final AtomicLongFieldUpdater inboundUncompressedSizeUpdater; - /** + /* * 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 * (potentially racy) direct updates of the volatile variables. diff --git a/census/src/main/java/io/grpc/census/CensusTracingModule.java b/census/src/main/java/io/grpc/census/CensusTracingModule.java index b507db10c6..ab56feff04 100644 --- a/census/src/main/java/io/grpc/census/CensusTracingModule.java +++ b/census/src/main/java/io/grpc/census/CensusTracingModule.java @@ -65,7 +65,7 @@ final class CensusTracingModule { @Nullable private static final AtomicIntegerFieldUpdater streamClosedUpdater; - /** + /* * 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 * (potentially racy) direct updates of the volatile variables. diff --git a/core/src/main/java/io/grpc/internal/BackoffPolicy.java b/core/src/main/java/io/grpc/internal/BackoffPolicy.java index cdca4a2260..c80ef9e1f9 100644 --- a/core/src/main/java/io/grpc/internal/BackoffPolicy.java +++ b/core/src/main/java/io/grpc/internal/BackoffPolicy.java @@ -20,7 +20,7 @@ package io.grpc.internal; * Determines how long to wait before doing some action (typically a retry, or a reconnect). */ public interface BackoffPolicy { - public interface Provider { + interface Provider { BackoffPolicy get(); } diff --git a/core/src/main/java/io/grpc/internal/DelayedClientCall.java b/core/src/main/java/io/grpc/internal/DelayedClientCall.java index df56fc0c5f..f529b0d0a0 100644 --- a/core/src/main/java/io/grpc/internal/DelayedClientCall.java +++ b/core/src/main/java/io/grpc/internal/DelayedClientCall.java @@ -121,6 +121,7 @@ public class DelayedClientCall extends ClientCall { buf.append(seconds); buf.append(String.format(Locale.US, ".%09d", nanos)); buf.append("s. "); + /** Cancels the call if deadline exceeded prior to the real call being set. */ class DeadlineExceededRunnable implements Runnable { @Override diff --git a/core/src/main/java/io/grpc/internal/InternalServer.java b/core/src/main/java/io/grpc/internal/InternalServer.java index 0445ae3dfa..a607908123 100644 --- a/core/src/main/java/io/grpc/internal/InternalServer.java +++ b/core/src/main/java/io/grpc/internal/InternalServer.java @@ -50,7 +50,7 @@ public interface InternalServer { 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. */ SocketAddress getListenSocketAddress(); @@ -61,7 +61,7 @@ public interface InternalServer { @Nullable InternalInstrumented 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. */ List getListenSocketAddresses(); diff --git a/core/src/main/java/io/grpc/internal/PickFirstLoadBalancerProvider.java b/core/src/main/java/io/grpc/internal/PickFirstLoadBalancerProvider.java index 0b11af94e2..7f7b366564 100644 --- a/core/src/main/java/io/grpc/internal/PickFirstLoadBalancerProvider.java +++ b/core/src/main/java/io/grpc/internal/PickFirstLoadBalancerProvider.java @@ -18,6 +18,7 @@ package io.grpc.internal; import io.grpc.LoadBalancer; import io.grpc.LoadBalancerProvider; +import io.grpc.NameResolver; import io.grpc.NameResolver.ConfigOrError; import java.util.Map; diff --git a/core/src/main/java/io/grpc/internal/StreamListener.java b/core/src/main/java/io/grpc/internal/StreamListener.java index 090c0555b0..a893a9c84b 100644 --- a/core/src/main/java/io/grpc/internal/StreamListener.java +++ b/core/src/main/java/io/grpc/internal/StreamListener.java @@ -59,6 +59,6 @@ public interface StreamListener { * messages until the producer returns null, at which point the producer may be discarded. */ @Nullable - public InputStream next(); + InputStream next(); } } diff --git a/core/src/main/java/io/grpc/util/AdvancedTlsX509KeyManager.java b/core/src/main/java/io/grpc/util/AdvancedTlsX509KeyManager.java index 9c9102b12c..1530834d60 100644 --- a/core/src/main/java/io/grpc/util/AdvancedTlsX509KeyManager.java +++ b/core/src/main/java/io/grpc/util/AdvancedTlsX509KeyManager.java @@ -246,7 +246,8 @@ public final class AdvancedTlsX509KeyManager extends X509ExtendedKeyManager { * Mainly used to avoid throwing IO Exceptions in java.io.Closeable. */ public interface Closeable extends java.io.Closeable { - @Override public void close(); + @Override + void close(); } } diff --git a/core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java b/core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java index 51bf57aeb3..7465e63210 100644 --- a/core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java +++ b/core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java @@ -295,7 +295,8 @@ public final class AdvancedTlsX509TrustManager extends X509ExtendedTrustManager // Mainly used to avoid throwing IO Exceptions in java.io.Closeable. public interface Closeable extends java.io.Closeable { - @Override public void close(); + @Override + void close(); } public static Builder newBuilder() { diff --git a/core/src/test/java/io/grpc/internal/ServiceConfigErrorHandlingTest.java b/core/src/test/java/io/grpc/internal/ServiceConfigErrorHandlingTest.java index 16c6f3bf30..6abb477878 100644 --- a/core/src/test/java/io/grpc/internal/ServiceConfigErrorHandlingTest.java +++ b/core/src/test/java/io/grpc/internal/ServiceConfigErrorHandlingTest.java @@ -236,7 +236,7 @@ public class ServiceConfigErrorHandlingTest { public void emptyAddresses_validConfig_firstResolution_lbNeedsAddress() throws Exception { FakeNameResolverFactory nameResolverFactory = new FakeNameResolverFactory.Builder(expectedUri) - .setServers(Collections.emptyList()) + .setServers(Collections.emptyList()) .build(); channelBuilder.nameResolverFactory(nameResolverFactory); @@ -299,7 +299,7 @@ public class ServiceConfigErrorHandlingTest { public void emptyAddresses_validConfig_lbDoesNotNeedAddress() throws Exception { FakeNameResolverFactory nameResolverFactory = new FakeNameResolverFactory.Builder(expectedUri) - .setServers(Collections.emptyList()) + .setServers(Collections.emptyList()) .build(); channelBuilder.nameResolverFactory(nameResolverFactory); when(mockLoadBalancer.canHandleEmptyAddressListFromNameResolution()).thenReturn(true); @@ -316,7 +316,7 @@ public class ServiceConfigErrorHandlingTest { ResolvedAddresses resolvedAddresses = resultCaptor.getValue(); assertThat(resolvedAddresses.getAddresses()).isEmpty(); - assertThat(resolvedAddresses.getLoadBalancingPolicyConfig()).isEqualTo("val");; + assertThat(resolvedAddresses.getLoadBalancingPolicyConfig()).isEqualTo("val"); verify(mockLoadBalancer, never()).handleNameResolutionError(any(Status.class)); assertThat(channel.getState(false)).isNotEqualTo(ConnectivityState.TRANSIENT_FAILURE); diff --git a/gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java b/gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java index b18fe741ae..c42d7b65c0 100644 --- a/gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java +++ b/gcp-observability/src/test/java/io/grpc/gcp/observability/GcpObservabilityTest.java @@ -223,7 +223,7 @@ public class GcpObservabilityTest { InternalLoggingChannelInterceptor.Factory channelInterceptorFactory = mock(InternalLoggingChannelInterceptor.Factory.class); InternalLoggingServerInterceptor.Factory serverInterceptorFactory = - mock(InternalLoggingServerInterceptor.Factory.class);; + mock(InternalLoggingServerInterceptor.Factory.class); try (GcpObservability unused = GcpObservability.grpcInit( diff --git a/netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java b/netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java index ab66472105..c94c05ffaf 100644 --- a/netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java +++ b/netty/src/main/java/io/grpc/netty/AbstractNettyHandler.java @@ -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. */ public interface PingLimiter { - public boolean isPingAllowed(); + boolean isPingAllowed(); } private static final class AllowPingLimiter implements PingLimiter { diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java index a7a1044059..dbfa8cf7ca 100644 --- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java +++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java @@ -251,7 +251,7 @@ class NettyClientTransport implements ConnectionClientTransport { ChannelHandler bufferingHandler = new WriteBufferingAndExceptionHandler(negotiationHandler); - /** + /* * 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 * that it may begin buffering writes. diff --git a/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java b/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java index 100367625f..2799dfccb6 100644 --- a/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java +++ b/netty/src/main/java/io/grpc/netty/WriteBufferingAndExceptionHandler.java @@ -184,7 +184,7 @@ final class WriteBufferingAndExceptionHandler extends ChannelDuplexHandler { */ @Override public void flush(ChannelHandlerContext ctx) { - /** + /* * Swallowing any flushes is not only an optimization but also required * for the SslHandler to work correctly. If the SslHandler receives multiple * flushes while the handshake is still ongoing, then the handshake "randomly" diff --git a/xds/src/main/java/io/grpc/xds/XdsNameResolver.java b/xds/src/main/java/io/grpc/xds/XdsNameResolver.java index ff9e4a10eb..d29132d1b2 100644 --- a/xds/src/main/java/io/grpc/xds/XdsNameResolver.java +++ b/xds/src/main/java/io/grpc/xds/XdsNameResolver.java @@ -822,7 +822,7 @@ final class XdsNameResolver extends NameResolver { existingClusters == null ? clusters : Sets.difference(clusters, existingClusters); Set deletedClusters = existingClusters == null - ? Collections.emptySet() : Sets.difference(existingClusters, clusters); + ? Collections.emptySet() : Sets.difference(existingClusters, clusters); existingClusters = clusters; for (String cluster : addedClusters) { if (clusterRefs.containsKey(cluster)) { @@ -982,7 +982,7 @@ final class XdsNameResolver extends NameResolver { final Map virtualHostOverrideConfig; private static RoutingConfig empty = new RoutingConfig( - 0L, Collections.emptyList(), null, Collections.emptyMap()); + 0, Collections.emptyList(), null, Collections.emptyMap()); private RoutingConfig( long fallbackTimeoutNano, List routes, @Nullable List filterChain, diff --git a/xds/src/main/java/io/grpc/xds/internal/sds/Closeable.java b/xds/src/main/java/io/grpc/xds/internal/sds/Closeable.java index c3695cecaf..3ac8734894 100644 --- a/xds/src/main/java/io/grpc/xds/internal/sds/Closeable.java +++ b/xds/src/main/java/io/grpc/xds/internal/sds/Closeable.java @@ -19,5 +19,5 @@ package io.grpc.xds.internal.sds; public interface Closeable extends java.io.Closeable { @Override - public void close(); + void close(); } diff --git a/xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java b/xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java index 25bd866424..8f4a2cf177 100644 --- a/xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java +++ b/xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java @@ -274,7 +274,7 @@ public class XdsNameResolverTest { .authorities( ImmutableMap.of(targetAuthority, AuthorityInfo.create( "xdstp://" + targetAuthority + "/envoy.config.listener.v3.Listener/%s?foo=1&bar=2", - ImmutableList.of(ServerInfo.create( + ImmutableList.of(ServerInfo.create( "td.googleapis.com", InsecureChannelCredentials.create(), true))))) .build(); expectedLdsResourceName = "xdstp://xds.authority.com/envoy.config.listener.v3.Listener/" @@ -299,12 +299,12 @@ public class XdsNameResolverTest { public void resolving_ldsResourceUpdateRdsName() { Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), - ImmutableMap.of()); + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), + ImmutableMap.of()); resolver.start(mockListener); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); @@ -313,7 +313,7 @@ public class XdsNameResolverTest { VirtualHost virtualHost = VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), Collections.singletonList(route1), - ImmutableMap.of()); + ImmutableMap.of()); xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost)); verify(mockListener).onResult(resolutionResultCaptor.capture()); assertServiceConfigForLoadBalancingConfig( @@ -329,7 +329,7 @@ public class XdsNameResolverTest { virtualHost = VirtualHost.create("virtualhost-alter", Collections.singletonList(AUTHORITY), Collections.singletonList(route2), - ImmutableMap.of()); + ImmutableMap.of()); xdsClient.deliverRdsUpdate(alternativeRdsResource, Collections.singletonList(virtualHost)); // Two new service config updates triggered: // - with load balancing config being able to select cluster1 and cluster2 @@ -357,8 +357,8 @@ public class XdsNameResolverTest { public void resolving_ldsResourceRevokedAndAddedBack() { Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); resolver.start(mockListener); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); @@ -367,7 +367,7 @@ public class XdsNameResolverTest { VirtualHost virtualHost = VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), Collections.singletonList(route), - ImmutableMap.of()); + ImmutableMap.of()); xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost)); verify(mockListener).onResult(resolutionResultCaptor.capture()); assertServiceConfigForLoadBalancingConfig( @@ -396,8 +396,8 @@ public class XdsNameResolverTest { public void resolving_rdsResourceRevokedAndAddedBack() { Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); resolver.start(mockListener); FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); @@ -406,7 +406,7 @@ public class XdsNameResolverTest { VirtualHost virtualHost = VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), Collections.singletonList(route), - ImmutableMap.of()); + ImmutableMap.of()); xdsClient.deliverRdsUpdate(RDS_RESOURCE_NAME, Collections.singletonList(virtualHost)); verify(mockListener).onResult(resolutionResultCaptor.capture()); assertServiceConfigForLoadBalancingConfig( @@ -473,12 +473,12 @@ public class XdsNameResolverTest { public void resolving_matchingVirtualHostNotFound_matchingOverrideAuthority() { Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); VirtualHost virtualHost = VirtualHost.create("virtualhost", Collections.singletonList("random"), Collections.singletonList(route), - ImmutableMap.of()); + ImmutableMap.of()); resolver = new XdsNameResolver(null, AUTHORITY, "random", serviceConfigParser, syncContext, scheduler, @@ -496,12 +496,12 @@ public class XdsNameResolverTest { public void resolving_matchingVirtualHostNotFound_notMatchingOverrideAuthority() { Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); VirtualHost virtualHost = VirtualHost.create("virtualhost", Collections.singletonList(AUTHORITY), Collections.singletonList(route), - ImmutableMap.of()); + ImmutableMap.of()); resolver = new XdsNameResolver(null, AUTHORITY, "random", serviceConfigParser, syncContext, scheduler, @@ -543,19 +543,19 @@ public class XdsNameResolverTest { private List buildUnmatchedVirtualHosts() { Route route1 = Route.forAction(RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); Route route2 = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()); + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), + ImmutableMap.of()); return Arrays.asList( VirtualHost.create("virtualhost-foo", Collections.singletonList("hello.googleapis.com"), Collections.singletonList(route1), - ImmutableMap.of()), + ImmutableMap.of()), VirtualHost.create("virtualhost-bar", Collections.singletonList("hi.googleapis.com"), Collections.singletonList(route2), - ImmutableMap.of())); + ImmutableMap.of())); } @Test @@ -564,11 +564,11 @@ public class XdsNameResolverTest { FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), null, null), // per-route timeout unset - ImmutableMap.of()); + cluster1, Collections.emptyList(), null, null), // per-route timeout unset + ImmutableMap.of()); VirtualHost virtualHost = VirtualHost.create("does not matter", Collections.singletonList(AUTHORITY), Collections.singletonList(route), - ImmutableMap.of()); + ImmutableMap.of()); xdsClient.deliverLdsUpdate(0L, Collections.singletonList(virtualHost)); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); @@ -582,11 +582,11 @@ public class XdsNameResolverTest { FakeXdsClient xdsClient = (FakeXdsClient) resolver.getXdsClient(); Route route = Route.forAction(RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), null, null), // per-route timeout unset - ImmutableMap.of()); + cluster1, Collections.emptyList(), null, null), // per-route timeout unset + ImmutableMap.of()); VirtualHost virtualHost = VirtualHost.create("does not matter", Collections.singletonList(AUTHORITY), Collections.singletonList(route), - ImmutableMap.of()); + ImmutableMap.of()); xdsClient.deliverLdsUpdate(TimeUnit.SECONDS.toNanos(5L), Collections.singletonList(virtualHost)); verify(mockListener).onResult(resolutionResultCaptor.capture()); @@ -612,10 +612,10 @@ public class XdsNameResolverTest { RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( cluster1, - Collections.emptyList(), + Collections.emptyList(), null, retryPolicy), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); @@ -668,12 +668,12 @@ public class XdsNameResolverTest { Arrays.asList( Route.forNonForwardingAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), - RouteAction.forCluster(cluster2, Collections.emptyList(), + RouteAction.forCluster(cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); assertThat(result.getAddresses()).isEmpty(); @@ -709,7 +709,7 @@ public class XdsNameResolverTest { HashPolicy.forHeader(false, "custom-key", null, null)), null, null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); InternalConfigSelector configSelector = resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY); @@ -743,7 +743,7 @@ public class XdsNameResolverTest { HashPolicy.forHeader(false, "custom-key", Pattern.compile("value"), "val")), null, null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); InternalConfigSelector configSelector = resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY); @@ -782,7 +782,7 @@ public class XdsNameResolverTest { Collections.singletonList(HashPolicy.forChannelId(false)), null, null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); InternalConfigSelector configSelector = resolutionResultCaptor.getValue().getAttributes().get(InternalConfigSelector.KEY); @@ -795,7 +795,7 @@ public class XdsNameResolverTest { // Second call, with no custom header. startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), + Collections.emptyMap(), CallOptions.DEFAULT); long hash2 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY); @@ -817,14 +817,14 @@ public class XdsNameResolverTest { Collections.singletonList(HashPolicy.forChannelId(false)), null, null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); configSelector = resolutionResultCaptor.getValue().getAttributes().get( InternalConfigSelector.KEY); // Third call, with no custom header. startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), + Collections.emptyMap(), CallOptions.DEFAULT); long hash3 = testCall.callOptions.getOption(XdsNameResolver.RPC_HASH_KEY); @@ -846,15 +846,15 @@ public class XdsNameResolverTest { Route.forAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - "another-cluster", Collections.emptyList(), + "another-cluster", Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); // Updated service config still contains cluster1 while it is removed resource. New calls no @@ -886,15 +886,15 @@ public class XdsNameResolverTest { Route.forAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - "another-cluster", Collections.emptyList(), + "another-cluster", Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); // Two consecutive service config updates: one for removing clcuster1, // one for adding "another=cluster". verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture()); @@ -922,15 +922,15 @@ public class XdsNameResolverTest { Route.forAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - "another-cluster", Collections.emptyList(), + "another-cluster", Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); @@ -943,15 +943,15 @@ public class XdsNameResolverTest { Route.forAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - "another-cluster", Collections.emptyList(), + "another-cluster", Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verifyNoMoreInteractions(mockListener); // no cluster added/deleted assertCallSelectClusterResult(call1, configSelector, "another-cluster", 15.0); } @@ -966,23 +966,23 @@ public class XdsNameResolverTest { Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); xdsClient.deliverLdsUpdate( Arrays.asList( Route.forAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); testCall.deliverErrorStatus(); verifyNoMoreInteractions(mockListener); } @@ -999,13 +999,13 @@ public class XdsNameResolverTest { RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forWeightedClusters( Arrays.asList( - ClusterWeight.create(cluster1, 20, ImmutableMap.of()), + ClusterWeight.create(cluster1, 20, ImmutableMap.of()), ClusterWeight.create( - cluster2, 80, ImmutableMap.of())), - Collections.emptyList(), + cluster2, 80, ImmutableMap.of())), + Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); assertThat(result.getAddresses()).isEmpty(); @@ -1031,10 +1031,10 @@ public class XdsNameResolverTest { "rls-plugin-foo", RlsPluginConfig.create( ImmutableMap.of("lookupService", "rls-cbt.googleapis.com"))), - Collections.emptyList(), + Collections.emptyList(), TimeUnit.SECONDS.toNanos(20L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); assertThat(result.getAddresses()).isEmpty(); @@ -1078,11 +1078,11 @@ public class XdsNameResolverTest { RlsPluginConfig.create( // changed ImmutableMap.of("lookupService", "rls-cbt-2.googleapis.com"))), - Collections.emptyList(), + Collections.emptyList(), // changed TimeUnit.SECONDS.toNanos(30L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener, times(2)).onResult(resolutionResultCaptor.capture()); ResolutionResult result2 = resolutionResultCaptor.getValue(); @SuppressWarnings("unchecked") @@ -1136,7 +1136,7 @@ public class XdsNameResolverTest { ClientInterceptor interceptor = result.getInterceptor(); ClientCall clientCall = interceptor.interceptCall( call.methodDescriptor, CallOptions.DEFAULT, channel); - clientCall.start(new NoopClientCallListener(), new Metadata()); + clientCall.start(new NoopClientCallListener<>(), new Metadata()); assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY)) .isEqualTo("cluster:" + expectedCluster); @SuppressWarnings("unchecked") @@ -1164,7 +1164,7 @@ public class XdsNameResolverTest { ClientInterceptor interceptor = result.getInterceptor(); ClientCall clientCall = interceptor.interceptCall( call.methodDescriptor, CallOptions.DEFAULT, channel); - clientCall.start(new NoopClientCallListener(), new Metadata()); + clientCall.start(new NoopClientCallListener<>(), new Metadata()); assertThat(testCall.callOptions.getOption(XdsNameResolver.CLUSTER_SELECTION_KEY)) .isEqualTo("cluster_specifier_plugin:" + expectedPluginName); @SuppressWarnings("unchecked") @@ -1186,15 +1186,15 @@ public class XdsNameResolverTest { Route.forAction( RouteMatch.withPathExactOnly(call1.getFullMethodNameForPath()), RouteAction.forCluster( - cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster1, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()), + ImmutableMap.of()), Route.forAction( RouteMatch.withPathExactOnly(call2.getFullMethodNameForPath()), RouteAction.forCluster( - cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), + cluster2, Collections.emptyList(), TimeUnit.SECONDS.toNanos(15L), null), - ImmutableMap.of()))); + ImmutableMap.of()))); verify(mockListener).onResult(resolutionResultCaptor.capture()); ResolutionResult result = resolutionResultCaptor.getValue(); assertThat(result.getAddresses()).isEmpty(); @@ -1329,7 +1329,7 @@ public class XdsNameResolverTest { 4, ImmutableList.of(Code.UNAVAILABLE, Code.CANCELLED), Durations.fromMillis(100), Durations.fromMillis(200), null); RetryPolicy retryPolicyWithEmptyStatusCodes = RetryPolicy.create( - 4, ImmutableList.of(), Durations.fromMillis(100), Durations.fromMillis(200), null); + 4, ImmutableList.of(), Durations.fromMillis(100), Durations.fromMillis(200), null); // timeout only String expectedServiceConfigJson = "{\n" @@ -1451,13 +1451,13 @@ public class XdsNameResolverTest { List routes = Collections.emptyList(); VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com", Arrays.asList("a.googleapis.com", "b.googleapis.com"), routes, - ImmutableMap.of()); + ImmutableMap.of()); VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com", Collections.singletonList("*.googleapis.com"), routes, - ImmutableMap.of()); + ImmutableMap.of()); VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com", Collections.singletonList("*"), routes, - ImmutableMap.of()); + ImmutableMap.of()); List virtualHosts = Arrays.asList(vHost1, vHost2, vHost3); assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname)) .isEqualTo(vHost1); @@ -1469,13 +1469,13 @@ public class XdsNameResolverTest { List routes = Collections.emptyList(); VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com", Arrays.asList("*.googleapis.com", "b.googleapis.com"), routes, - ImmutableMap.of()); + ImmutableMap.of()); VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com", Collections.singletonList("a.googleapis.*"), routes, - ImmutableMap.of()); + ImmutableMap.of()); VirtualHost vHost3 = VirtualHost.create("virtualhost03.googleapis.com", Collections.singletonList("*"), routes, - ImmutableMap.of()); + ImmutableMap.of()); List virtualHosts = Arrays.asList(vHost1, vHost2, vHost3); assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname)) .isEqualTo(vHost1); @@ -1487,13 +1487,13 @@ public class XdsNameResolverTest { List routes = Collections.emptyList(); VirtualHost vHost1 = VirtualHost.create("virtualhost01.googleapis.com", Collections.singletonList("*"), routes, - ImmutableMap.of()); + ImmutableMap.of()); VirtualHost vHost2 = VirtualHost.create("virtualhost02.googleapis.com", Collections.singletonList("b.googleapis.com"), routes, - ImmutableMap.of()); + ImmutableMap.of()); List virtualHosts = Arrays.asList(vHost1, vHost2); assertThat(XdsNameResolver.findVirtualHostForHostName(virtualHosts, hostname)) - .isEqualTo(vHost1);; + .isEqualTo(vHost1); } @Test @@ -1513,7 +1513,7 @@ public class XdsNameResolverTest { InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); // no header abort key provided in metadata, rpc should succeed ClientCall.Listener observer = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcSucceeded(observer); // header abort http status key provided, rpc should fail observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, @@ -1582,7 +1582,7 @@ public class XdsNameResolverTest { result = resolutionResultCaptor.getValue(); configSelector = result.getAttributes().get(InternalConfigSelector.KEY); observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), CallOptions.DEFAULT); + Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcFailed( observer, Status.UNAUTHENTICATED.withDescription( @@ -1600,7 +1600,7 @@ public class XdsNameResolverTest { result = resolutionResultCaptor.getValue(); configSelector = result.getAttributes().get(InternalConfigSelector.KEY); observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), CallOptions.DEFAULT); + Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcSucceeded(observer); } @@ -1619,7 +1619,7 @@ public class XdsNameResolverTest { InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); // no header delay key provided in metadata, rpc should succeed immediately ClientCall.Listener observer = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcSucceeded(observer); // header delay key provided, rpc should be delayed observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, @@ -1659,7 +1659,7 @@ public class XdsNameResolverTest { result = resolutionResultCaptor.getValue(); configSelector = result.getAttributes().get(InternalConfigSelector.KEY); observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), CallOptions.DEFAULT); + Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcDelayed(observer, 5000L); // fixed delay, fix rate = 40% @@ -1672,7 +1672,7 @@ public class XdsNameResolverTest { result = resolutionResultCaptor.getValue(); configSelector = result.getAttributes().get(InternalConfigSelector.KEY); observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), CallOptions.DEFAULT); + Collections.emptyMap(), CallOptions.DEFAULT); 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 // because maxActiveFaults is exceeded. ClientCall.Listener observer1 = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); assertThat(testCall).isNull(); ClientCall.Listener observer2 = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcSucceeded(observer2); verifyRpcDelayed(observer1, 5000L); // Once all calls are finished, new call should be delayed. ClientCall.Listener observer3 = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcDelayed(observer3, 5000L); } @@ -1728,7 +1728,7 @@ public class XdsNameResolverTest { } }; ClientCall.Listener observer = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT.withDeadline( + configSelector, Collections.emptyMap(), CallOptions.DEFAULT.withDeadline( Deadline.after(4000, TimeUnit.NANOSECONDS, fakeTicker))); assertThat(testCall).isNull(); verifyRpcDelayedThenAborted(observer, 4000L, Status.DEADLINE_EXCEEDED.withDescription( @@ -1753,7 +1753,7 @@ public class XdsNameResolverTest { ResolutionResult result = resolutionResultCaptor.getValue(); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); ClientCall.Listener observer = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcDelayedThenAborted( observer, 5000L, Status.UNAUTHENTICATED.withDescription( @@ -1782,7 +1782,7 @@ public class XdsNameResolverTest { ResolutionResult result = resolutionResultCaptor.getValue(); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); ClientCall.Listener observer = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT); + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcFailed( observer, Status.INTERNAL.withDescription("RPC terminated due to fault injection")); @@ -1797,7 +1797,7 @@ public class XdsNameResolverTest { result = resolutionResultCaptor.getValue(); configSelector = result.getAttributes().get(InternalConfigSelector.KEY); observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), CallOptions.DEFAULT); + Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcFailed( observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection")); @@ -1814,7 +1814,7 @@ public class XdsNameResolverTest { result = resolutionResultCaptor.getValue(); configSelector = result.getAttributes().get(InternalConfigSelector.KEY); observer = startNewCall(TestMethodDescriptors.voidMethod(), configSelector, - Collections.emptyMap(), CallOptions.DEFAULT); + Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcFailed( observer, Status.UNAVAILABLE.withDescription("RPC terminated due to fault injection")); } @@ -1843,7 +1843,7 @@ public class XdsNameResolverTest { ResolutionResult result = resolutionResultCaptor.getValue(); InternalConfigSelector configSelector = result.getAttributes().get(InternalConfigSelector.KEY); ClientCall.Listener observer = startNewCall(TestMethodDescriptors.voidMethod(), - configSelector, Collections.emptyMap(), CallOptions.DEFAULT);; + configSelector, Collections.emptyMap(), CallOptions.DEFAULT); verifyRpcFailed( observer, Status.UNKNOWN.withDescription("RPC terminated due to fault injection")); } @@ -1904,7 +1904,7 @@ public class XdsNameResolverTest { RouteMatch routeMatch1 = RouteMatch.create( PathMatcher.fromPath("/FooService/barMethod", true), - Collections.emptyList(), null); + Collections.emptyList(), null); assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/barMethod", headers, random)) .isTrue(); assertThat(XdsNameResolver.matchRoute(routeMatch1, "/FooService/bazMethod", headers, random)) @@ -1913,7 +1913,7 @@ public class XdsNameResolverTest { RouteMatch routeMatch2 = RouteMatch.create( PathMatcher.fromPrefix("/FooService/", true), - Collections.emptyList(), null); + Collections.emptyList(), null); assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/barMethod", headers, random)) .isTrue(); assertThat(XdsNameResolver.matchRoute(routeMatch2, "/FooService/bazMethod", headers, random)) @@ -1924,7 +1924,7 @@ public class XdsNameResolverTest { RouteMatch routeMatch3 = RouteMatch.create( PathMatcher.fromRegEx(Pattern.compile(".*Foo.*")), - Collections.emptyList(), null); + Collections.emptyList(), null); assertThat(XdsNameResolver.matchRoute(routeMatch3, "/FooService/barMethod", headers, random)) .isTrue(); } @@ -1937,14 +1937,14 @@ public class XdsNameResolverTest { RouteMatch routeMatch1 = RouteMatch.create( PathMatcher.fromPath("/FooService/barMethod", false), - Collections.emptyList(), null); + Collections.emptyList(), null); assertThat(XdsNameResolver.matchRoute(routeMatch1, "/fooservice/barmethod", headers, random)) .isTrue(); RouteMatch routeMatch2 = RouteMatch.create( PathMatcher.fromPrefix("/FooService", false), - Collections.emptyList(), null); + Collections.emptyList(), null); assertThat(XdsNameResolver.matchRoute(routeMatch2, "/fooservice/barmethod", headers, random)) .isTrue(); } @@ -2122,7 +2122,7 @@ public class XdsNameResolverTest { VirtualHost virtualHost = VirtualHost.create( "virtual-host", Collections.singletonList(expectedLdsResourceName), routes, - ImmutableMap.of()); + ImmutableMap.of()); ldsWatcher.onChanged(LdsUpdate.forApiListener(HttpConnectionManager.forVirtualHosts( 0L, Collections.singletonList(virtualHost), null))); } @@ -2140,28 +2140,28 @@ public class XdsNameResolverTest { new NamedFilterConfig(FAULT_FILTER_INSTANCE_NAME, httpFilterFaultConfig), new NamedFilterConfig(ROUTER_FILTER_INSTANCE_NAME, RouterFilter.ROUTER_CONFIG)); ImmutableMap overrideConfig = weightedClusterFaultConfig == null - ? ImmutableMap.of() - : ImmutableMap.of( + ? ImmutableMap.of() + : ImmutableMap.of( FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig); ClusterWeight clusterWeight = ClusterWeight.create( cluster, 100, overrideConfig); overrideConfig = routeFaultConfig == null - ? ImmutableMap.of() - : ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routeFaultConfig); + ? ImmutableMap.of() + : ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routeFaultConfig); Route route = Route.forAction( RouteMatch.create( - PathMatcher.fromPrefix("/", false), Collections.emptyList(), null), + PathMatcher.fromPrefix("/", false), Collections.emptyList(), null), RouteAction.forWeightedClusters( Collections.singletonList(clusterWeight), - Collections.emptyList(), + Collections.emptyList(), null, null), overrideConfig); overrideConfig = virtualHostFaultConfig == null - ? ImmutableMap.of() - : ImmutableMap.of( + ? ImmutableMap.of() + : ImmutableMap.of( FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig); VirtualHost virtualHost = VirtualHost.create( "virtual-host", @@ -2201,26 +2201,26 @@ public class XdsNameResolverTest { return; } ImmutableMap overrideConfig = weightedClusterFaultConfig == null - ? ImmutableMap.of() - : ImmutableMap.of( + ? ImmutableMap.of() + : ImmutableMap.of( FAULT_FILTER_INSTANCE_NAME, weightedClusterFaultConfig); ClusterWeight clusterWeight = ClusterWeight.create(cluster1, 100, overrideConfig); overrideConfig = routFaultConfig == null - ? ImmutableMap.of() - : ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routFaultConfig); + ? ImmutableMap.of() + : ImmutableMap.of(FAULT_FILTER_INSTANCE_NAME, routFaultConfig); Route route = Route.forAction( RouteMatch.create( - PathMatcher.fromPrefix("/", false), Collections.emptyList(), null), + PathMatcher.fromPrefix("/", false), Collections.emptyList(), null), RouteAction.forWeightedClusters( Collections.singletonList(clusterWeight), - Collections.emptyList(), + Collections.emptyList(), null, null), overrideConfig); overrideConfig = virtualHostFaultConfig == null - ? ImmutableMap.of() - : ImmutableMap.of( + ? ImmutableMap.of() + : ImmutableMap.of( FAULT_FILTER_INSTANCE_NAME, virtualHostFaultConfig); VirtualHost virtualHost = VirtualHost.create( "virtual-host",