Skip to content

Commit a332edd

Browse files
authored
fix: cleans up FileWatcherCertificateProvider in XdsSecurityClientServerTest
1 parent 350f90e commit a332edd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

xds/src/test/java/io/grpc/xds/XdsSecurityClientServerTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public class XdsSecurityClientServerTest {
130130
private FakeXdsClient xdsClient = new FakeXdsClient();
131131
private FakeXdsClientPoolFactory fakePoolFactory = new FakeXdsClientPoolFactory(xdsClient);
132132
private static final String OVERRIDE_AUTHORITY = "foo.test.google.fr";
133+
private Attributes sslContextAttributes;
133134

134135
@Parameters(name = "enableSpiffe={0}")
135136
public static Collection<Boolean> data() {
@@ -152,6 +153,14 @@ public void tearDown() throws IOException {
152153
NameResolverRegistry.getDefaultRegistry().deregister(fakeNameResolverFactory);
153154
}
154155
FileWatcherCertificateProviderProvider.enableSpiffe = originalEnableSpiffe;
156+
if (sslContextAttributes != null) {
157+
SslContextProviderSupplier sslContextProviderSupplier = sslContextAttributes.get(
158+
SecurityProtocolNegotiators.ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER);
159+
if (sslContextProviderSupplier != null) {
160+
sslContextProviderSupplier.close();
161+
}
162+
sslContextAttributes = null;
163+
}
155164
}
156165

157166
@Test
@@ -651,7 +660,7 @@ private SimpleServiceGrpc.SimpleServiceBlockingStub getBlockingStub(
651660
InetSocketAddress socketAddress =
652661
new InetSocketAddress(Inet4Address.getLoopbackAddress(), port);
653662
tlsContextManagerForClient = new TlsContextManagerImpl(bootstrapInfoForClient);
654-
Attributes attrs =
663+
sslContextAttributes =
655664
(upstreamTlsContext != null)
656665
? Attributes.newBuilder()
657666
.set(SecurityProtocolNegotiators.ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER,
@@ -660,7 +669,7 @@ private SimpleServiceGrpc.SimpleServiceBlockingStub getBlockingStub(
660669
.build()
661670
: Attributes.EMPTY;
662671
fakeNameResolverFactory.setServers(
663-
ImmutableList.of(new EquivalentAddressGroup(socketAddress, attrs)));
672+
ImmutableList.of(new EquivalentAddressGroup(socketAddress, sslContextAttributes)));
664673
return SimpleServiceGrpc.newBlockingStub(cleanupRule.register(channelBuilder.build()));
665674
}
666675

0 commit comments

Comments
 (0)