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 at DefaultEventProcessor #193

Open
orafaaraujo opened this issue Nov 3, 2022 · 5 comments
Open

NullPointerException at DefaultEventProcessor #193

orafaaraujo opened this issue Nov 3, 2022 · 5 comments

Comments

@orafaaraujo
Copy link

Hello

Describe the bug
We are facing a crash in the library.

To reproduce
We're unable to reproduce it, but according to our logs on Firebase, it happens once the app goes to the background.

Expected behavior
No crash at all

Logs
The stack trace

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
       at libcore.reflect.TypeVariableImpl.hashCode(TypeVariableImpl.java:47)
       at java.util.HashMap.hash(HashMap.java:338)
       at java.util.HashMap.get(HashMap.java:556)
       at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:353)
       at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:396)
       at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:343)
       at com.google.gson.internal.$Gson$Types.getSupertype($Gson$Types.java:288)
       at com.google.gson.internal.$Gson$Types.getCollectionElementType($Gson$Types.java:307)
       at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:52)
       at com.google.gson.Gson.getAdapter(Gson.java:489)
       at com.google.gson.Gson.toJson(Gson.java:727)
       at com.google.gson.Gson.toJson(Gson.java:714)
       at com.google.gson.Gson.toJson(Gson.java:669)
       at com.google.gson.Gson.toJson(Gson.java:649)
       at com.launchdarkly.sdk.android.DefaultEventProcessor$Consumer.postEvents(DefaultEventProcessor.java:145)
       at com.launchdarkly.sdk.android.DefaultEventProcessor$Consumer.flush(DefaultEventProcessor.java:139)
       at com.launchdarkly.sdk.android.DefaultEventProcessor$Consumer.run(DefaultEventProcessor.java:122)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
       at java.lang.Thread.run(Thread.java:1012)

SDK version
3.1.5

Language version, developer tools
Kotlin 1.6, AGP 7.3.1, Android 33

OS/platform
Android 12 (API 33)

Additional context
Screenshot 2022-11-03 at 11 49 54

@louis-launchdarkly
Copy link
Contributor

Hello @orafaaraujo, thank you for the report on this issue. While this event loop call should not cause any real issues for your application (the event loop is on a separate thread that doesn't impact getting and using flag values), this is still something that we need to look into.

While there is no exact ETA yet, we also have a new major version in the pipeline that will improve Android in general, we will reply on this either when we have new information or when the new version comes out.

Filed Internally as 175693.

@audkar
Copy link
Contributor

audkar commented Dec 3, 2022

While this event loop call should not cause any real issues for your application (the event loop is on a separate thread

Android system sets default global uncaught exception handler to kill whole process. It doesn't matter that Exception is thrown on separate thread.

that doesn't impact getting and using flag values

This impacts not just getting/using flags, but whole production application is terminated. That's what being reported in stack-trace: Fatal Exception. Whole process goes kaput ☠️

@louis-launchdarkly
Copy link
Contributor

louis-launchdarkly commented Dec 15, 2022

@audkar Thank you for the information.

@orafaaraujo We have released 4.0.0 which fully replaced the DefaultEventProcessor that was in android with an improved one. If it is possible for you to upgrade, can you upgrade and let us know if this issue is still happening? For the upgrade path, please refer to https://github.com/launchdarkly/android-client-sdk/blob/main/CHANGELOG.md#400---2022-12-07

@DmytroBatyuk
Copy link

try to use

     LDContext.builder("unknown")
            .anonymous(true)
            .build()

while initializing a client. LDContext should have not empty key

@louis-launchdarkly
Copy link
Contributor

Thank you @DmytroBatyuk for the answer - we are currently looking into potentially revamping the key generation behavior as Android requiring the placeholder key is something that can be missed and some other LaunchDarkly SDKs don't do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants