xds: shutDown the scheduledExecutorService when the provider is shutdown (#8198)

This commit is contained in:
sanjaypujare 2021-05-24 12:45:01 -07:00 committed by GitHub
parent c8cd4cb260
commit 5b1c3fa12c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -82,6 +82,7 @@ final class FileWatcherCertificateProvider extends CertificateProvider implement
@Override
public synchronized void close() {
shutdown = true;
scheduledExecutorService.shutdownNow();
if (scheduledFuture != null) {
scheduledFuture.cancel(true);
scheduledFuture = null;

View File

@ -180,6 +180,7 @@ public class FileWatcherCertificateProviderTest {
.updateCertificate(any(PrivateKey.class), ArgumentMatchers.<X509Certificate>anyList());
verify(mockWatcher, never()).updateTrustedRoots(ArgumentMatchers.<X509Certificate>anyList());
verify(timeService, never()).schedule(any(Runnable.class), any(Long.TYPE), any(TimeUnit.class));
verify(timeService, times(1)).shutdownNow();
}