Skip to content

Commit

Permalink
[ISSUE-#4631] Free credential instance when serverHttpAgent shutdown. (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
horizonzy authored Jan 11, 2021
1 parent 0732a93 commit a4e3b7c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ public void shutdown() throws NacosException {
LOGGER.info("{} do shutdown begin", className);
ThreadUtils.shutdownThreadPool(executorService, LOGGER);
ConfigHttpClientManager.getInstance().shutdown();
SpasAdapter.freeCredentialInstance();
LOGGER.info("{} do shutdown stop", className);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public static String getAk() {
return CredentialService.getInstance().getCredential().getAccessKey();
}

public static void freeCredentialInstance() {
CredentialService.freeInstance();
}

/**
* Sign with hmac SHA1 encrtpt.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ public void shutdown() throws NacosException {
NAMING_LOGGER.info("{} do shutdown begin", className);
ThreadUtils.shutdownThreadPool(executorService, NAMING_LOGGER);
NamingHttpClientManager.getInstance().shutdown();
SpasAdapter.freeCredentialInstance();
NAMING_LOGGER.info("{} do shutdown stop", className);
}
}
Expand Down

0 comments on commit a4e3b7c

Please sign in to comment.