am 6ccd708a: am 0e406003: Merge "Fix crash/OOM in DiskBasedCache"

* commit '6ccd708adf345337137a7ef8efa6fd618afa7bc4':
  Fix crash/OOM in DiskBasedCache
diff --git a/src/com/android/volley/toolbox/DiskBasedCache.java b/src/com/android/volley/toolbox/DiskBasedCache.java
index 2a4761b..d397aad 100644
--- a/src/com/android/volley/toolbox/DiskBasedCache.java
+++ b/src/com/android/volley/toolbox/DiskBasedCache.java
@@ -61,7 +61,7 @@
     private static final float HYSTERESIS_FACTOR = 0.9f;
 
     /** Magic number for current version of cache file format. */
-    private static final int CACHE_MAGIC = 0x20120504;
+    private static final int CACHE_MAGIC = 0x20140623;
 
     /**
      * Constructs an instance of the DiskBasedCache at the specified directory.
@@ -197,7 +197,12 @@
         try {
             FileOutputStream fos = new FileOutputStream(file);
             CacheHeader e = new CacheHeader(key, entry);
-            e.writeHeader(fos);
+            boolean success = e.writeHeader(fos);
+            if (!success) {
+                fos.close();
+                VolleyLog.d("Failed to write header for %s", file.getAbsolutePath());
+                throw new IOException();
+            }
             fos.write(entry.data);
             fos.close();
             putEntry(key, e);