kill cleaner thread on service stop

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/oauth@141891 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
costantino.perciante 2017-01-29 17:54:43 +00:00
parent 807cea8e60
commit cd61182ac6
1 changed files with 14 additions and 3 deletions

View File

@ -43,6 +43,11 @@ public class OauthService {
*/
private Map<String, CacheBean> entries;
/**
* Cleaner thread
*/
CacheCleaner cleaner;
/**
* Since this is a singleton sub-service, there will be just one call to this constructor and one running thread
* to clean up expired codes.
@ -50,10 +55,16 @@ public class OauthService {
public OauthService() {
logger.info("Singleton gcube-oauth service built.");
entries = new ConcurrentHashMap<String, CacheBean>();
CacheCleaner cleaner = new CacheCleaner(entries);
cleaner = new CacheCleaner(entries);
cleaner.start();
}
@Override
protected void finalize(){
if(cleaner != null)
cleaner.interrupt();
}
/**
* Used to check that the token type is of type user
* @param clientType