Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in LruMemoryCache #233

Closed
gildor opened this issue Apr 5, 2013 · 5 comments
Closed

NullPointerException in LruMemoryCache #233

gildor opened this issue Apr 5, 2013 · 5 comments
Labels

Comments

@gildor
Copy link

gildor commented Apr 5, 2013

Hi! We have some rare (1 per 2000 users) errors in logs with UIL 1.8.3.
All users have Android 2.X

java.lang.NullPointerException: key == null || value == null
    at com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache.put(LruMemoryCache.java:61)
    at com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache.put(LruMemoryCache.java:21)
    at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:116)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
    at java.lang.Thread.run(Thread.java:1019)

our configuration:

DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
        builder.cacheInMemory();
        builder.cacheOnDisc();
        builder.resetViewBeforeLoading();
        builder.showImageForEmptyUri(R.drawable.im_photo_error);
@nostra13
Copy link
Owner

nostra13 commented Apr 5, 2013

Thanks for bug. I'll investigate it.

DisplayImageOptions is display options. Can you provide your configuration (ImageLoaderConfiguration)?

@gildor
Copy link
Author

gildor commented Apr 5, 2013

My configuration is simple:

ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(mContext);
        if (App.DEBUG) {
            builder.enableLogging();
        }
        builder.discCacheSize(DISC_CACHE_SIZE);
        builder.defaultDisplayImageOptions(getDisplayImageConfig().build());

where getDisplayImageConfig is listed above

@nostra13
Copy link
Owner

nostra13 commented Apr 5, 2013

Mystery. Can't imagine how it can happens. Don't you really use any pre-processor?

@gildor
Copy link
Author

gildor commented Apr 7, 2013

Sorry, you're right. In some cases, we use preprocessor:

public class MaskClipProcessor implements BitmapProcessor {

    public static final int DEFAULT_MASK = R.drawable.user_mask_album;
    private final Bitmap mMask;
    private static HashMap<Integer, Bitmap> cachedMaskBitmaps = new HashMap<Integer, Bitmap>();

    public MaskClipProcessor(int mask) {
        if (cachedMaskBitmaps.containsKey(mask)) {
            mMask = cachedMaskBitmaps.get(mask);
        } else {
            mMask = BitmapFactory.decodeResource(App.getContext().getResources(), mask);
            cachedMaskBitmaps.put(mask, mMask);
        }
    }

    @Override
    public Bitmap process(Bitmap bitmap) {
        return Utils.getRoundedCornerBitmapByMask(bitmap, mMask);
    }

}

@nostra13
Copy link
Owner

nostra13 commented Apr 7, 2013

I'll fix it, NPE won't be thrown, UIL will display null (nothing) if you return it. But I recommend you to return original bitmap if processing failed.

nostra13 added a commit that referenced this issue Apr 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants