ImageManager cacheImage NullPointer exception #101

hastoukopsaro opened this Issue Mar 28, 2013 · 7 comments


None yet
6 participants

I was using the cacheImage helper method from ImageManager and noticed that the if statement below will always throw a null pointer when using LruCache, was it meant to be (b != null)?

if (b == null) {
   // decode failed
   loaderSettings.getCacheManager().put(url, b);

peter-budo was assigned Apr 14, 2013


peter-budo commented Apr 14, 2013

I will have look at it and let you know 😉


peter-budo commented Apr 21, 2013

@hastoukopsaro would you be kind to share with us scenario or specific code in which you are getting this exception? I tried few things but didn't hit exception


ouchadam commented Apr 22, 2013

I've been getting this error as well.

    java.lang.NullPointerException: key == null
    at com.novoda.imageloader.core.cache.util.LruCache.get(
    at com.novoda.imageloader.core.cache.LruBitmapCache.get(
    at com.novoda.imageloader.core.loader.ConcurrentLoader.getCachedBitmap(
    at com.novoda.imageloader.core.loader.ConcurrentLoader.loadBitmap(
    at com.novoda.imageloader.core.loader.ConcurrentLoader.load(

charroch commented Apr 22, 2013

me 2, I believe it is relating to an adapter which would load up views and potentially recycle them when not needed. A way to reproduce is reload an adapter with a new one and then scroll. First adapter having 100 element, second 10. When you reach the 11's view, you ll get the crash.


Dorvaryn commented Apr 22, 2013

@hastoukopsaro Same here I can't manage to reproduce the bug, I tried to change the adapter cursor with a smaller size after load but it didn't throw the exception.
I'm willing to get it done if you can share with us scenario or specific code in which you are getting this exception.

From my understanding the getBitmapUtil().decode* might fail in various occasions. The if statement checks if the decoded Bitmap is null and if TRUE it goes to cache manager and puts a null . In LRU this will definitely throw an exception.

I guess the issue here is why the decoder is failing.. but if we move past that... why are deliberately putting a null value to the cache (which will throw an exception) am i making any sense?


blundell commented Apr 13, 2016

sorry repo now deprecated

blundell closed this Apr 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment