summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Blitzstein <sblitz@google.com>2014-10-20 12:17:47 -0700
committerSam Blitzstein <sblitz@google.com>2014-10-20 12:19:53 -0700
commit4309c1f708f469a5ab3ac52b6b22cc6ede1d50ff (patch)
tree37f315a5c4ea91ff1d51583406db289254b80f57
parent3a79e2002f9f6114b549c4bc2cc08bb10e75a4d2 (diff)
downloadbitmap-4309c1f708f469a5ab3ac52b6b22cc6ede1d50ff.tar.gz
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
-rw-r--r--src/com/android/bitmap/DecodeTask.java7
1 files changed, 5 insertions, 2 deletions
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 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> {
}
}
- // 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) {