Abort can throw same illegal state as commit
So don't try to abort if disk cache is closed and
catch all errors in error handeling code so we
don't cause a crash trying to abort a failed
commit
diff --git a/library/src/com/bumptech/photos/resize/cache/PhotoDiskCache.java b/library/src/com/bumptech/photos/resize/cache/PhotoDiskCache.java
index 9181b53..be6d320 100644
--- a/library/src/com/bumptech/photos/resize/cache/PhotoDiskCache.java
+++ b/library/src/com/bumptech/photos/resize/cache/PhotoDiskCache.java
@@ -72,16 +72,14 @@
edit = cache.edit(safeKey);
out = new BufferedOutputStream(edit.newOutputStream(VALUE_COUNT - 1));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
- if (cache.isClosed()) {
- edit.abort();
- } else {
+ if (!cache.isClosed()) {
edit.commit();
}
} catch (Exception e) {
if (edit != null) {
try {
edit.abort();
- } catch (IOException e1) {
+ } catch (Exception e1) {
e1.printStackTrace();
}
}