From ed5072e1481c2f355e4f8b2e3eab92f1a7a7b7cd Mon Sep 17 00:00:00 2001 From: Kannan J Date: Tue, 20 May 2025 07:19:41 +0000 Subject: [PATCH 1/8] Add Docker fiels for xds example server and client. --- examples/example-xds/xds-client.Dockerfile | 47 ++++++++++++++++++++++ examples/example-xds/xds-server.Dockerfile | 47 ++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 examples/example-xds/xds-client.Dockerfile create mode 100644 examples/example-xds/xds-server.Dockerfile diff --git a/examples/example-xds/xds-client.Dockerfile b/examples/example-xds/xds-client.Dockerfile new file mode 100644 index 00000000000..0f34d219177 --- /dev/null +++ b/examples/example-xds/xds-client.Dockerfile @@ -0,0 +1,47 @@ +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Stage 1: Build XDS client +# + +FROM eclipse-temurin:11-jdk AS build + +WORKDIR /grpc-java/examples +COPY . . + +RUN cd example-xds && ../gradlew installDist -PskipCodegen=true -PskipAndroid=true + +# +# Stage 2: +# +# - Copy only the necessary files to reduce Docker image size. +# - Have an ENTRYPOINT script which will launch the XDS client +# with the given parameters. +# + +FROM eclipse-temurin:11-jre + +WORKDIR /grpc-java/ +COPY --from=build /grpc-java/examples/example-xds/build/install/example-xds/. . + +# Intentionally after the COPY to force the update on each build. +# Update Ubuntu system packages: +RUN apt-get update \ + && apt-get -y upgrade \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +# Client +ENTRYPOINT ["bin/xds-hello-world-client"] diff --git a/examples/example-xds/xds-server.Dockerfile b/examples/example-xds/xds-server.Dockerfile new file mode 100644 index 00000000000..542fb0263af --- /dev/null +++ b/examples/example-xds/xds-server.Dockerfile @@ -0,0 +1,47 @@ +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Stage 1: Build XDS server +# + +FROM eclipse-temurin:11-jdk AS build + +WORKDIR /grpc-java/examples +COPY . . + +RUN cd example-xds && ../gradlew installDist -PskipCodegen=true -PskipAndroid=true + +# +# Stage 2: +# +# - Copy only the necessary files to reduce Docker image size. +# - Have an ENTRYPOINT script which will launch the XDS server +# with the given parameters. +# + +FROM eclipse-temurin:11-jre + +WORKDIR /grpc-java/ +COPY --from=build /grpc-java/examples/example-xds/build/install/example-xds/. . + +# Intentionally after the COPY to force the update on each build. +# Update Ubuntu system packages: +RUN apt-get update \ + && apt-get -y upgrade \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +# Server +ENTRYPOINT ["bin/xds-hello-world-server"] From 233b4151b6f87cf8ff273524e27c1c3a26261d47 Mon Sep 17 00:00:00 2001 From: deadEternally Date: Wed, 2 Jul 2025 12:37:36 +0530 Subject: [PATCH 2/8] in-progress changes. --- .../java/io/grpc/rls/CachingRlsLbClient.java | 20 +++++-------------- .../io/grpc/rls/CachingRlsLbClientTest.java | 10 ++++++---- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java b/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java index 70833416d5d..56c5bdc1547 100644 --- a/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java +++ b/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java @@ -132,6 +132,7 @@ final class CachingRlsLbClient { @GuardedBy("lock") private final RefCountedChildPolicyWrapperFactory refCountedChildPolicyWrapperFactory; private final ChannelLogger logger; + private final ChildPolicyWrapper fallbackChildPolicyWrapper; static { MetricInstrumentRegistry metricInstrumentRegistry @@ -226,6 +227,10 @@ private CachingRlsLbClient(Builder builder) { lbPolicyConfig.getLoadBalancingPolicy(), childLbResolvedAddressFactory, childLbHelperProvider, new BackoffRefreshListener()); + // TODO(creamsoup) wait until lb is ready + String defaultTarget = lbPolicyConfig.getRouteLookupConfig().defaultTarget(); + logger.log(ChannelLogLevel.DEBUG, "starting fallback to {0}", defaultTarget); + fallbackChildPolicyWrapper = refCountedChildPolicyWrapperFactory.createOrGet(defaultTarget); gaugeRegistration = helper.getMetricRecorder() .registerBatchCallback(new BatchCallback() { @@ -1015,12 +1020,8 @@ public PickResult pickSubchannel(PickSubchannelArgs args) { } } - private ChildPolicyWrapper fallbackChildPolicyWrapper; - /** Uses Subchannel connected to default target. */ private PickResult useFallback(PickSubchannelArgs args) { - // TODO(creamsoup) wait until lb is ready - startFallbackChildPolicy(); SubchannelPicker picker = fallbackChildPolicyWrapper.getPicker(); if (picker == null) { return PickResult.withNoResult(); @@ -1045,17 +1046,6 @@ private String determineMetricsPickResult(PickResult pickResult) { } } - private void startFallbackChildPolicy() { - String defaultTarget = lbPolicyConfig.getRouteLookupConfig().defaultTarget(); - synchronized (lock) { - if (fallbackChildPolicyWrapper != null) { - return; - } - logger.log(ChannelLogLevel.DEBUG, "starting fallback to {0}", defaultTarget); - fallbackChildPolicyWrapper = refCountedChildPolicyWrapperFactory.createOrGet(defaultTarget); - } - } - // GuardedBy CachingRlsLbClient.lock void close() { synchronized (lock) { // Lock is already held, but ErrorProne can't tell diff --git a/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java b/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java index 7c5df2c96b3..17d0fe94976 100644 --- a/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java +++ b/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java @@ -372,12 +372,14 @@ public void get_updatesLbState() throws Exception { ArgumentCaptor pickerCaptor = ArgumentCaptor.forClass(SubchannelPicker.class); ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ConnectivityState.class); - inOrder.verify(helper, times(2)) + inOrder.verify(helper, times(3)) .updateBalancingState(stateCaptor.capture(), pickerCaptor.capture()); assertThat(new HashSet<>(pickerCaptor.getAllValues())).hasSize(1); + // TRANSIENT_FAILURE is because the test setup pretends fallback is not available. assertThat(stateCaptor.getAllValues()) - .containsExactly(ConnectivityState.CONNECTING, ConnectivityState.READY); + .containsExactly(ConnectivityState.TRANSIENT_FAILURE, ConnectivityState.CONNECTING, + ConnectivityState.READY); Metadata headers = new Metadata(); PickResult pickResult = getPickResultForCreate(pickerCaptor, headers); assertThat(pickResult.getStatus().isOk()).isTrue(); @@ -439,7 +441,7 @@ public void timeout_not_changing_picked_subchannel() throws Exception { ArgumentCaptor pickerCaptor = ArgumentCaptor.forClass(SubchannelPicker.class); ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ConnectivityState.class); - verify(helper, times(4)).updateBalancingState(stateCaptor.capture(), pickerCaptor.capture()); + verify(helper, times(5)).updateBalancingState(stateCaptor.capture(), pickerCaptor.capture()); Metadata headers = new Metadata(); PickResult pickResult = getPickResultForCreate(pickerCaptor, headers); @@ -509,7 +511,7 @@ public void get_withAdaptiveThrottler() throws Exception { ArgumentCaptor pickerCaptor = ArgumentCaptor.forClass(SubchannelPicker.class); ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ConnectivityState.class); - inOrder.verify(helper, times(2)) + inOrder.verify(helper, times(3)) .updateBalancingState(stateCaptor.capture(), pickerCaptor.capture()); Metadata headers = new Metadata(); From 28a1f5102565731a8043cc11aab864f0b435e982 Mon Sep 17 00:00:00 2001 From: deadEternally Date: Fri, 11 Jul 2025 18:06:39 +0530 Subject: [PATCH 3/8] Fix test. --- rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java b/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java index 17d0fe94976..1ba6689b723 100644 --- a/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java +++ b/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java @@ -169,6 +169,7 @@ public void uncaughtException(Thread t, Throwable e) { private CachingRlsLbClient rlsLbClient; private Map rlsChannelServiceConfig; private String rlsChannelOverriddenAuthority; + private boolean isAlreadyClosed = false; private void setUpRlsLbClient() { fakeThrottler.resetCounts(); @@ -191,7 +192,9 @@ public void setUpMockMetricRecorder() { @After public void tearDown() throws Exception { - rlsLbClient.close(); + if (!isAlreadyClosed) { + rlsLbClient.close(); + } assertWithMessage( "On client shut down, RlsLoadBalancer must shut down with all its child loadbalancers.") .that(lbProvider.loadBalancers).isEmpty(); @@ -702,6 +705,7 @@ public void metricGauges() throws ExecutionException, InterruptedException, Time // Shutdown rlsLbClient.close(); verify(mockGaugeRegistration).close(); + isAlreadyClosed = true; } private static RouteLookupConfig getRouteLookupConfig() { From a60c797646293e9a7abfe85f1e76d4ae591549b5 Mon Sep 17 00:00:00 2001 From: deadEternally Date: Fri, 11 Jul 2025 18:10:14 +0530 Subject: [PATCH 4/8] Remove pollution from unrelated file changes. --- examples/example-xds/xds-client.Dockerfile | 47 ---------------------- examples/example-xds/xds-server.Dockerfile | 47 ---------------------- 2 files changed, 94 deletions(-) delete mode 100644 examples/example-xds/xds-client.Dockerfile delete mode 100644 examples/example-xds/xds-server.Dockerfile diff --git a/examples/example-xds/xds-client.Dockerfile b/examples/example-xds/xds-client.Dockerfile deleted file mode 100644 index 0f34d219177..00000000000 --- a/examples/example-xds/xds-client.Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2024 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Stage 1: Build XDS client -# - -FROM eclipse-temurin:11-jdk AS build - -WORKDIR /grpc-java/examples -COPY . . - -RUN cd example-xds && ../gradlew installDist -PskipCodegen=true -PskipAndroid=true - -# -# Stage 2: -# -# - Copy only the necessary files to reduce Docker image size. -# - Have an ENTRYPOINT script which will launch the XDS client -# with the given parameters. -# - -FROM eclipse-temurin:11-jre - -WORKDIR /grpc-java/ -COPY --from=build /grpc-java/examples/example-xds/build/install/example-xds/. . - -# Intentionally after the COPY to force the update on each build. -# Update Ubuntu system packages: -RUN apt-get update \ - && apt-get -y upgrade \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* - -# Client -ENTRYPOINT ["bin/xds-hello-world-client"] diff --git a/examples/example-xds/xds-server.Dockerfile b/examples/example-xds/xds-server.Dockerfile deleted file mode 100644 index 542fb0263af..00000000000 --- a/examples/example-xds/xds-server.Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2024 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# Stage 1: Build XDS server -# - -FROM eclipse-temurin:11-jdk AS build - -WORKDIR /grpc-java/examples -COPY . . - -RUN cd example-xds && ../gradlew installDist -PskipCodegen=true -PskipAndroid=true - -# -# Stage 2: -# -# - Copy only the necessary files to reduce Docker image size. -# - Have an ENTRYPOINT script which will launch the XDS server -# with the given parameters. -# - -FROM eclipse-temurin:11-jre - -WORKDIR /grpc-java/ -COPY --from=build /grpc-java/examples/example-xds/build/install/example-xds/. . - -# Intentionally after the COPY to force the update on each build. -# Update Ubuntu system packages: -RUN apt-get update \ - && apt-get -y upgrade \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* - -# Server -ENTRYPOINT ["bin/xds-hello-world-server"] From db0b2832d7c8990f74136e48ede70e8dc845d49e Mon Sep 17 00:00:00 2001 From: deadEternally Date: Fri, 11 Jul 2025 18:44:00 +0530 Subject: [PATCH 5/8] Don't create fallback policy if default target is null. --- rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java | 8 ++++++-- rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java b/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java index 56c5bdc1547..79af953a21e 100644 --- a/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java +++ b/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java @@ -229,8 +229,12 @@ private CachingRlsLbClient(Builder builder) { new BackoffRefreshListener()); // TODO(creamsoup) wait until lb is ready String defaultTarget = lbPolicyConfig.getRouteLookupConfig().defaultTarget(); - logger.log(ChannelLogLevel.DEBUG, "starting fallback to {0}", defaultTarget); - fallbackChildPolicyWrapper = refCountedChildPolicyWrapperFactory.createOrGet(defaultTarget); + if (defaultTarget != null && !defaultTarget.isEmpty()) { + logger.log(ChannelLogLevel.DEBUG, "starting fallback to {0}", defaultTarget); + fallbackChildPolicyWrapper = refCountedChildPolicyWrapperFactory.createOrGet(defaultTarget); + } else { + fallbackChildPolicyWrapper = null; + } gaugeRegistration = helper.getMetricRecorder() .registerBatchCallback(new BatchCallback() { diff --git a/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java b/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java index f3986cb89d5..72fd3bdc117 100644 --- a/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java +++ b/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java @@ -257,7 +257,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception { inOrder.verifyNoMoreInteractions(); assertThat(res.getStatus().isOk()).isTrue(); - assertThat(subchannels).hasSize(1); + assertThat(subchannels).hasSize(2); // includes fallback sub-channel FakeSubchannel searchSubchannel = subchannels.getLast(); assertThat(subchannelIsReady(searchSubchannel)).isFalse(); @@ -277,7 +277,7 @@ public void lb_working_withDefaultTarget_rlsResponding() throws Exception { // other rls picker itself is ready due to first channel. assertThat(res.getStatus().isOk()).isTrue(); assertThat(subchannelIsReady(res.getSubchannel())).isFalse(); - assertThat(subchannels).hasSize(2); + assertThat(subchannels).hasSize(3); // includes fallback sub-channel FakeSubchannel rescueSubchannel = subchannels.getLast(); // search subchannel is down, rescue subchannel is connecting @@ -545,7 +545,7 @@ public void lb_nameResolutionFailed() throws Exception { assertThat(subchannelIsReady(res.getSubchannel())).isFalse(); inOrder.verify(helper).createSubchannel(any(CreateSubchannelArgs.class)); - assertThat(subchannels).hasSize(1); + assertThat(subchannels).hasSize(1); // includes fallback sub-channel FakeSubchannel searchSubchannel = subchannels.getLast(); searchSubchannel.updateState(ConnectivityStateInfo.forNonError(ConnectivityState.READY)); From 8fb30c97f6d80e61b85cdcc3d340f7e40356a8cd Mon Sep 17 00:00:00 2001 From: deadEternally Date: Fri, 11 Jul 2025 18:48:23 +0530 Subject: [PATCH 6/8] Fix test --- rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java b/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java index 72fd3bdc117..d85ab170578 100644 --- a/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java +++ b/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java @@ -545,7 +545,7 @@ public void lb_nameResolutionFailed() throws Exception { assertThat(subchannelIsReady(res.getSubchannel())).isFalse(); inOrder.verify(helper).createSubchannel(any(CreateSubchannelArgs.class)); - assertThat(subchannels).hasSize(1); // includes fallback sub-channel + assertThat(subchannels).hasSize(2); // includes fallback sub-channel FakeSubchannel searchSubchannel = subchannels.getLast(); searchSubchannel.updateState(ConnectivityStateInfo.forNonError(ConnectivityState.READY)); From 1fdfa0b988ab63dfa7cad524d70a158d94ecf967 Mon Sep 17 00:00:00 2001 From: deadEternally Date: Fri, 11 Jul 2025 20:20:32 +0530 Subject: [PATCH 7/8] After doing eager init for the fallback policy child wrapper in CachingRlsLbClient, there is a need to call deliveryResolvedAddress() inside synch context, that eventually calls acceptResolvedAdddresses for the fallback policy wrapper. --- .../java/io/grpc/rls/RlsLoadBalancerTest.java | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java b/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java index d85ab170578..354466f3caf 100644 --- a/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java +++ b/rls/src/test/java/io/grpc/rls/RlsLoadBalancerTest.java @@ -201,7 +201,13 @@ public void tearDown() { @Test public void lb_serverStatusCodeConversion() throws Exception { - deliverResolvedAddresses(); + helper.getSynchronizationContext().execute(() -> { + try { + deliverResolvedAddresses(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); InOrder inOrder = inOrder(helper); inOrder.verify(helper) .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture()); @@ -236,7 +242,13 @@ public void lb_serverStatusCodeConversion() throws Exception { @Test public void lb_working_withDefaultTarget_rlsResponding() throws Exception { - deliverResolvedAddresses(); + helper.getSynchronizationContext().execute(() -> { + try { + deliverResolvedAddresses(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); InOrder inOrder = inOrder(helper); inOrder.verify(helper) .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture()); @@ -393,7 +405,13 @@ public void lb_working_withoutDefaultTarget_noRlsResponse() throws Exception { public void lb_working_withDefaultTarget_noRlsResponse() throws Exception { fakeThrottler.nextResult = true; - deliverResolvedAddresses(); + helper.getSynchronizationContext().execute(() -> { + try { + deliverResolvedAddresses(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); InOrder inOrder = inOrder(helper); inOrder.verify(helper) .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture()); @@ -535,7 +553,13 @@ public void lb_working_withoutDefaultTarget() throws Exception { @Test public void lb_nameResolutionFailed() throws Exception { - deliverResolvedAddresses(); + helper.getSynchronizationContext().execute(() -> { + try { + deliverResolvedAddresses(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); InOrder inOrder = inOrder(helper); inOrder.verify(helper) .updateBalancingState(eq(ConnectivityState.CONNECTING), pickerCaptor.capture()); From 0a3ffc082c848bbff03f09d82f15b75b9b46080d Mon Sep 17 00:00:00 2001 From: deadEternally Date: Mon, 14 Jul 2025 12:28:23 +0530 Subject: [PATCH 8/8] Review comments. --- rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java | 1 - rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java b/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java index 736cc7a76f3..cc3ac9f516e 100644 --- a/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java +++ b/rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java @@ -230,7 +230,6 @@ private CachingRlsLbClient(Builder builder) { // TODO(creamsoup) wait until lb is ready String defaultTarget = lbPolicyConfig.getRouteLookupConfig().defaultTarget(); if (defaultTarget != null && !defaultTarget.isEmpty()) { - logger.log(ChannelLogLevel.DEBUG, "starting fallback to {0}", defaultTarget); fallbackChildPolicyWrapper = refCountedChildPolicyWrapperFactory.createOrGet(defaultTarget); } else { fallbackChildPolicyWrapper = null; diff --git a/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java b/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java index 1ba6689b723..4f086abc4a2 100644 --- a/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java +++ b/rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java @@ -169,7 +169,6 @@ public void uncaughtException(Thread t, Throwable e) { private CachingRlsLbClient rlsLbClient; private Map rlsChannelServiceConfig; private String rlsChannelOverriddenAuthority; - private boolean isAlreadyClosed = false; private void setUpRlsLbClient() { fakeThrottler.resetCounts(); @@ -192,7 +191,7 @@ public void setUpMockMetricRecorder() { @After public void tearDown() throws Exception { - if (!isAlreadyClosed) { + if (rlsLbClient != null) { rlsLbClient.close(); } assertWithMessage( @@ -704,8 +703,8 @@ public void metricGauges() throws ExecutionException, InterruptedException, Time // Shutdown rlsLbClient.close(); + rlsLbClient = null; verify(mockGaugeRegistration).close(); - isAlreadyClosed = true; } private static RouteLookupConfig getRouteLookupConfig() {