For cancelled decodes, skip the cache save, since it may be incorrect
Especially if it's null, this would cause future cache hits to think the key
has a null result
Bug: 17721894
Change-Id: I7930f8ab8515c8ea8201a0594fc2cbf228959b7b
diff --git a/src/com/android/bitmap/DecodeTask.java b/src/com/android/bitmap/DecodeTask.java
index 0f12bae..77b5982 100644
--- a/src/com/android/bitmap/DecodeTask.java
+++ b/src/com/android/bitmap/DecodeTask.java
@@ -440,8 +440,11 @@
}
}
- // Put result in cache, regardless of null. The cache will handle null results.
- mCache.put(mKey, result);
+ // Cancellations can't be guaranteed to be correct, so skip the cache
+ if (!isCancelled()) {
+ // Put result in cache, regardless of null. The cache will handle null results.
+ mCache.put(mKey, result);
+ }
if (result != null) {
result.acquireReference();
if (DEBUG) {