private void storeData ( Job key , TileBitmap bitmap ) { OutputStream outputStream = null ; try { File file = getOutputFile ( key ) ; if ( file == null ) { // if the file cannot be written, silently return return ; } outputStream = new FileOutputStream ( file ) ; bitmap . compress ( outputStream ) ; try { lock . writeLock ( ) . lock ( ) ; if ( this . lruCache . put ( key . getKey ( ) , file ) != null ) { LOGGER . warning ( "overwriting cached entry: " + key . getKey ( ) ) ; } } finally { lock . writeLock ( ) . unlock ( ) ; } } catch ( Exception e ) { // we are catching now any exception and then disable the file cache // this should ensure that no exception in the storage thread will // ever crash the main app. If there is a runtime exception, the thread // will exit (via destroy). LOGGER . log ( Level . SEVERE , "Disabling filesystem cache" , e ) ; // most likely cause is that the disk is full, just disable the // cache otherwise // more and more exceptions will be thrown. this . destroy ( ) ; try { lock . writeLock ( ) . lock ( ) ; this . lruCache = new FileWorkingSetCache < String > ( 0 ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } finally { IOUtils . closeQuietly ( outputStream ) ; } }
stores the bitmap data on disk with filename key