[ISSUE-#4631] Free credential instance when serverHttpAgent shutdown. (#4634)

* free credential instance when serverHttpAgent shutdown.

* free credential instance when namingProxy shutdown.

* unify the code place

* cancel timer when CredentialWatcher stop

* ignore PMD.AvoidUseTimerRule.
This commit is contained in:
赵延 2021-01-11 09:59:44 +08:00 committed by GitHub
parent 0732a93072
commit a4e3b7cbc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 1 deletions

View File

@ -453,6 +453,7 @@ public class ServerHttpAgent implements HttpAgent {
LOGGER.info("{} do shutdown begin", className);
ThreadUtils.shutdownThreadPool(executorService, LOGGER);
ConfigHttpClientManager.getInstance().shutdown();
SpasAdapter.freeCredentialInstance();
LOGGER.info("{} do shutdown stop", className);
}

View File

@ -74,6 +74,10 @@ public class SpasAdapter {
return CredentialService.getInstance().getCredential().getAccessKey();
}
public static void freeCredentialInstance() {
CredentialService.freeInstance();
}
/**
* Sign with hmac SHA1 encrtpt.
*

View File

@ -53,7 +53,6 @@ public class CredentialWatcher {
private final ScheduledExecutorService executor;
@SuppressWarnings("PMD.AvoidUseTimerRule")
public CredentialWatcher(String appName, CredentialService serviceInstance) {
this.appName = appName;
this.serviceInstance = serviceInstance;

View File

@ -719,6 +719,7 @@ public class NamingProxy implements Closeable {
NAMING_LOGGER.info("{} do shutdown begin", className);
ThreadUtils.shutdownThreadPool(executorService, NAMING_LOGGER);
NamingHttpClientManager.getInstance().shutdown();
SpasAdapter.freeCredentialInstance();
NAMING_LOGGER.info("{} do shutdown stop", className);
}
}