private static DataStore readCacheFileAsFallback ( @ Nonnull final DataReader reader , @ Nonnull final File cacheFile , @ Nonnull final Charset charset , @ Nonnull final DataStore fallback ) { DataStore fallbackDataStore ; if ( ! isEmpty ( cacheFile , charset ) ) { final URL cacheFileUrl = UrlUtil . toUrl ( cacheFile ) ; try { fallbackDataStore = new CacheFileDataStore ( reader . read ( cacheFileUrl , charset ) , reader , cacheFileUrl , charset ) ; LOG . debug ( MSG_CACHE_FILE_IS_FILLED ) ; } catch ( final RuntimeException e ) { fallbackDataStore = fallback ; deleteCacheFile ( cacheFile ) ; } } else { fallbackDataStore = fallback ; LOG . debug ( MSG_CACHE_FILE_IS_EMPTY ) ; } return fallbackDataStore ; }
Tries to read the content of specified cache file and returns them as fallback data store . If the cache file contains unexpected data the given fallback data store will be returned instead .