GCX-HCI / tray

a SharedPreferences replacement for Android with multiprocess support
Apache License 2.0
2.29k stars 273 forks source link

NullPointerException in ContentProviderStorage.java:104 #124

Open BiglyBT opened 6 years ago

BiglyBT commented 6 years ago

tray Version

0.12.0

How have you setup tray

Initialized on a new thread invoked from Application.onCreate. registerOnTrayPreferenceChangeListener called in a separate class with a OnTrayPreferenceChangeListener parameter of this (ie. it isn't null)

Device(s)

Motorola Moto G (5) Plus (potter_n)

Android Version (E.g. Marshmallow or better API 23)

Android 7.0

Stacktrace

Stacktrace ``` java.lang.NullPointerException: at net.grandcentrix.tray.provider.ContentProviderStorage$TrayContentObserver$1.run (ContentProviderStorage.java:104) at android.os.Handler.handleCallback (Handler.java:751) at android.os.Handler.dispatchMessage (Handler.java:95) at android.os.Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6123) at java.lang.reflect.Method.invoke (Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:757) ```

Description

I'm guessing my class that implements OnTrayPreferenceChangeListener is GC'd at one point. I see that the ContentProviderStorage uses a WeakHashMap, but does some other magic stuff (cloning, etc) which perhaps breaks the rule that they key will never be null. Or there's some other problem, I really don't know :O

I have only one registerOnTrayPreferenceChangeListener call, so I can guarantee I never try to call it with null (even if I did, the registerOnTrayPreferenceChangeListener code would catch the null listener)

rzetzsche commented 6 years ago

+1