Skip to content
Permalink
Browse files
Adding additional checks
  • Loading branch information
effrafax committed Nov 1, 2021
1 parent 10474d5 commit c9a0171e60732315cfb6756af336f32e28c605f7
Showing 1 changed file with 21 additions and 2 deletions.
@@ -37,8 +37,10 @@

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
* EhcacheCache
@@ -231,6 +233,18 @@ public void initialize( )
{
configuration = new Configuration( );
}
Path diskStore = Paths.get( getDiskStorePath( ) );
if (!Files.exists( diskStore ))
{
try
{
Files.createDirectories( diskStore );
}
catch ( IOException e )
{
log.error( "Could not create cache path " + e.getMessage( ) );
}
}
this.cacheManager = new CacheManager( configuration.name( getName( ) ).diskStore(
new DiskStoreConfiguration( ).path( getDiskStorePath( ) ) ) );
}
@@ -297,8 +311,13 @@ public void dispose( )
log.info( "Disposing cache: {}", ehcache );
if ( this.ehcache != null )
{
this.cacheManager.removeCache( this.ehcache.getName( ) );
this.ehcache = null;
try
{
this.cacheManager.removeCache( this.ehcache.getName( ) );
this.ehcache = null;
} catch (Throwable e) {
log.error( "Cache removal failed: {}", e.getMessage( ), e );
}
}
}
else

0 comments on commit c9a0171

Please sign in to comment.