@Test public void entryShouldBeNull() { Entry entry = discCache.get(null); assertNull(entry); }
@Override public Entry get(String key) { if (key == null) { return null; } File file = this.delegate.get(key); if (file == null || !file.exists()) { return null; } CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader header = CacheHeader.readHeader(cis); byte[] data = StreamUtils.streamToBytes(cis, (int) (file.length() - cis.bytesRead)); return header.toCacheEntry(data); } catch (IOException e) { VolleyLog.e(e, "Exception in file path %s", file.getAbsolutePath()); remove(key); return null; } finally { IoUtils.closeQuietly(cis); } }
UniversalDiscCache implements Cache { @Override public Entry get(String key) { if (key == null) { return null; } File file = this.delegate.get(key); if (file == null || !file.exists()) { return null; } CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader header = CacheHeader.readHeader(cis); byte[] data = StreamUtils.streamToBytes(cis, (int) (file.length() - cis.bytesRead)); return header.toCacheEntry(data); } catch (IOException e) { VolleyLog.e(e, "Exception in file path %s", file.getAbsolutePath()); remove(key); return null; } finally { IoUtils.closeQuietly(cis); } } }
UniversalDiscCache implements Cache { @Override public Entry get(String key) { if (key == null) { return null; } File file = this.delegate.get(key); if (file == null || !file.exists()) { return null; } CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader header = CacheHeader.readHeader(cis); byte[] data = StreamUtils.streamToBytes(cis, (int) (file.length() - cis.bytesRead)); return header.toCacheEntry(data); } catch (IOException e) { VolleyLog.e(e, "Exception in file path %s", file.getAbsolutePath()); remove(key); return null; } finally { IoUtils.closeQuietly(cis); } } UniversalDiscCache(DiscCacheAware delegate); }
UniversalDiscCache implements Cache { @Override public Entry get(String key) { if (key == null) { return null; } File file = this.delegate.get(key); if (file == null || !file.exists()) { return null; } CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader header = CacheHeader.readHeader(cis); byte[] data = StreamUtils.streamToBytes(cis, (int) (file.length() - cis.bytesRead)); return header.toCacheEntry(data); } catch (IOException e) { VolleyLog.e(e, "Exception in file path %s", file.getAbsolutePath()); remove(key); return null; } finally { IoUtils.closeQuietly(cis); } } UniversalDiscCache(DiscCacheAware delegate); @Override void clear(); @Override Entry get(String key); @Override void put(String key, Entry entry); @Override void initialize(); @Override void invalidate(String key, boolean arg1); @Override void remove(String key); }
UniversalDiscCache implements Cache { @Override public Entry get(String key) { if (key == null) { return null; } File file = this.delegate.get(key); if (file == null || !file.exists()) { return null; } CountingInputStream cis = null; try { cis = new CountingInputStream(new FileInputStream(file)); CacheHeader header = CacheHeader.readHeader(cis); byte[] data = StreamUtils.streamToBytes(cis, (int) (file.length() - cis.bytesRead)); return header.toCacheEntry(data); } catch (IOException e) { VolleyLog.e(e, "Exception in file path %s", file.getAbsolutePath()); remove(key); return null; } finally { IoUtils.closeQuietly(cis); } } UniversalDiscCache(DiscCacheAware delegate); @Override void clear(); @Override Entry get(String key); @Override void put(String key, Entry entry); @Override void initialize(); @Override void invalidate(String key, boolean arg1); @Override void remove(String key);  }