NPE on BitmapLruCache.getFromDiskCache(BitmapLruCache.java:225) #5

Closed
tamsler opened this Issue Feb 18, 2013 · 1 comment

Projects

None yet

2 participants

@tamsler
tamsler commented Feb 18, 2013

I am getting the following NPE:

Android-BitmapCache v2.1

02-18 00:18:53.701: E/AndroidRuntime(15150): FATAL EXCEPTION: AsyncTask #2
02-18 00:18:53.701: E/AndroidRuntime(15150): java.lang.RuntimeException: An error occured while executing doInBackground()
02-18 00:18:53.701: E/AndroidRuntime(15150): at android.os.AsyncTask$3.done(AsyncTask.java:200)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.lang.Thread.run(Thread.java:1019)
02-18 00:18:53.701: E/AndroidRuntime(15150): Caused by: java.lang.NullPointerException
02-18 00:18:53.701: E/AndroidRuntime(15150): at uk.co.senab.bitmapcache.BitmapLruCache.getFromDiskCache(BitmapLruCache.java:225)
02-18 00:18:53.701: E/AndroidRuntime(15150): at uk.co.senab.bitmapcache.BitmapLruCache.get(BitmapLruCache.java:189)
02-18 00:18:53.701: E/AndroidRuntime(15150): at uk.co.senab.bitmapcache.BitmapLruCache.get(BitmapLruCache.java:167)
02-18 00:18:53.701: E/AndroidRuntime(15150): at org.thomasamsler.android.polling.service.ImageService$DownloadImageTask.doInBackground(ImageService.java:195)
02-18 00:18:53.701: E/AndroidRuntime(15150): at org.thomasamsler.android.polling.service.ImageService$DownloadImageTask.doInBackground(ImageService.java:1)
02-18 00:18:53.701: E/AndroidRuntime(15150): at android.os.AsyncTask$2.call(AsyncTask.java:185)
02-18 00:18:53.701: E/AndroidRuntime(15150): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
02-18 00:18:53.701: E/AndroidRuntime(15150): ... 4 more

@tamsler
tamsler commented Feb 18, 2013

This issue is caused by setting setMemoryCacheEnabled() as follows. Removing setMemoryCacheEnabled(false) gets rid of the NPE.

BitmapLruCache.Builder builder = new BitmapLruCache.Builder();
builder.setMemoryCacheEnabled(false);
builder.setDiskCacheEnabled(true).setDiskCacheLocation(cacheLocation);

@chrisbanes chrisbanes closed this Feb 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment