Skip to content

Commit 0e40600

Browse files
Ficus KirkpatrickGerrit Code Review
authored andcommitted
Merge "Fix crash/OOM in DiskBasedCache"
2 parents 527f964 + 5bd5325 commit 0e40600

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/com/android/volley/toolbox/DiskBasedCache.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class DiskBasedCache implements Cache {
6161
private static final float HYSTERESIS_FACTOR = 0.9f;
6262

6363
/** Magic number for current version of cache file format. */
64-
private static final int CACHE_MAGIC = 0x20120504;
64+
private static final int CACHE_MAGIC = 0x20140623;
6565

6666
/**
6767
* Constructs an instance of the DiskBasedCache at the specified directory.
@@ -197,7 +197,12 @@ public synchronized void put(String key, Entry entry) {
197197
try {
198198
FileOutputStream fos = new FileOutputStream(file);
199199
CacheHeader e = new CacheHeader(key, entry);
200-
e.writeHeader(fos);
200+
boolean success = e.writeHeader(fos);
201+
if (!success) {
202+
fos.close();
203+
VolleyLog.d("Failed to write header for %s", file.getAbsolutePath());
204+
throw new IOException();
205+
}
201206
fos.write(entry.data);
202207
fos.close();
203208
putEntry(key, e);

0 commit comments

Comments
 (0)