@@ -130,6 +130,7 @@ public class XdsSecurityClientServerTest {
130
130
private FakeXdsClient xdsClient = new FakeXdsClient ();
131
131
private FakeXdsClientPoolFactory fakePoolFactory = new FakeXdsClientPoolFactory (xdsClient );
132
132
private static final String OVERRIDE_AUTHORITY = "foo.test.google.fr" ;
133
+ private Attributes sslContextAttributes ;
133
134
134
135
@ Parameters (name = "enableSpiffe={0}" )
135
136
public static Collection <Boolean > data () {
@@ -152,6 +153,14 @@ public void tearDown() throws IOException {
152
153
NameResolverRegistry .getDefaultRegistry ().deregister (fakeNameResolverFactory );
153
154
}
154
155
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
+ }
155
164
}
156
165
157
166
@ Test
@@ -651,7 +660,7 @@ private SimpleServiceGrpc.SimpleServiceBlockingStub getBlockingStub(
651
660
InetSocketAddress socketAddress =
652
661
new InetSocketAddress (Inet4Address .getLoopbackAddress (), port );
653
662
tlsContextManagerForClient = new TlsContextManagerImpl (bootstrapInfoForClient );
654
- Attributes attrs =
663
+ sslContextAttributes =
655
664
(upstreamTlsContext != null )
656
665
? Attributes .newBuilder ()
657
666
.set (SecurityProtocolNegotiators .ATTR_SSL_CONTEXT_PROVIDER_SUPPLIER ,
@@ -660,7 +669,7 @@ private SimpleServiceGrpc.SimpleServiceBlockingStub getBlockingStub(
660
669
.build ()
661
670
: Attributes .EMPTY ;
662
671
fakeNameResolverFactory .setServers (
663
- ImmutableList .of (new EquivalentAddressGroup (socketAddress , attrs )));
672
+ ImmutableList .of (new EquivalentAddressGroup (socketAddress , sslContextAttributes )));
664
673
return SimpleServiceGrpc .newBlockingStub (cleanupRule .register (channelBuilder .build ()));
665
674
}
666
675
0 commit comments