@ SuppressWarnings ( "unchecked" ) private Map < String , String > loadOrCreateCache ( String projectName , String projectVersion ) { if ( projectName != null && projectVersion != null ) { // Get the project dir or create it File projectDir = new File ( getCacheDir ( ) , projectName ) ; if ( ! projectDir . exists ( ) ) { projectDir . mkdir ( ) ; } // Get the version file or create it File versionFile = new File ( projectDir , projectVersion ) ; if ( versionFile . exists ( ) ) { ObjectInputStream ois = null ; try { ois = new ObjectInputStream ( new FileInputStream ( versionFile ) ) ; return ( Map < String , String > ) ois . readObject ( ) ; } catch ( IOException ioe ) { LOGGER . warn ( "Unable to read the cache for {}-{}" , projectName , projectVersion ) ; } catch ( ClassNotFoundException cnfe ) { LOGGER . warn ( "The cache for {}-{} is corrupted." , projectName , projectVersion ) ; } finally { if ( ois != null ) { try { ois . close ( ) ; } catch ( IOException ioe ) { } } } } } return new HashMap <> ( ) ; }
Try to load the cache from file if not available a new cache is created