launchdarkly / android-client-sdk

LaunchDarkly Client-side SDK for Android
Other
45 stars 23 forks source link

ConcurrentModificationException inside ConnectivityReceiver.onReceive #76

Closed Fando closed 5 years ago

Fando commented 5 years ago

There is a ConcurrentModificationException inside ConnectivityReceiver.onReceive. Below are the logs for this crash.

Also, a similar thing might be happening inside PollingUpdater.onReceive, no crash logs for this, but there is a ANR report on the Play Console that refers to the PollingUpdater which seems to contain similar code to the ConnectivityReceiver.

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4200010 (has extras) } in com.launchdarkly.android.ConnectivityReceiver@f08c875
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1493)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(-.java:2)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7045)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by java.util.ConcurrentModificationException
       at java.util.HashMap$HashIterator.nextNode(HashMap.java:1441)
       at java.util.HashMap$KeyIterator.next(HashMap.java:1465)
       at com.launchdarkly.android.ConnectivityReceiver.onReceive(ConnectivityReceiver.java:29)
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1483)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(-.java:2)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7045)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)

SDK version com.launchdarkly:launchdarkly-android-client-sdk:2.8.3

Language version, developer tools Java 7

OS/platform Android 8 and 9

gwhelanLD commented 5 years ago

Hi @Fando,

Thanks for the report. This looks like it's caused by the receiver being called while the client is still being initialized. I'll be taking more of a look at this issue, and will update you when I have more information.

Thanks, @gwhelanLD

gwhelanLD commented 5 years ago

Hi @Fando,

We've just released version 2.8.4 of the Android SDK with a fix for this issue. It contains some minor restructuring to move all iteration over the LDClient instance map to within the class. This allows us to synchronize these operations to prevent any access while initialization is occurring.

Thank you for reporting this issue, we appreciate your patience as we got this release ready. Feel free to reach out here on the Github issue tracker or through support channels if you run into any more issues.

Thanks, @gwhelanLD

gwhelanLD commented 5 years ago

Hi @Fando,

I'm going to close out this issue as 2.8.4 should fix the issue. Feel free to reopen if you continue running into this issue with 2.8.4.

Thanks, @gwhelanLD

tanmaythakar4 commented 4 years ago

@gwhelanLD , I have similar issue on SDK implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.8.5' Below are the logs for this,

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4200010 (has extras) } in g51$r@d6c462d
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0 + 1493(LoadedApk.java:1493)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run + 2(:2)
       at android.os.Handler.handleCallback + 873(Handler.java:873)
       at android.os.Handler.dispatchMessage + 99(Handler.java:99)
       at android.os.Looper.loop + 214(Looper.java:214)
       at android.app.ActivityThread.main + 7073(ActivityThread.java:7073)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkInfo.isConnected()' on a null object reference
       at rh.e + 3(SourceFile:3)
       at g51$r.onReceive + 3(SourceFile:3)
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0 + 1483(LoadedApk.java:1483)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run + 2(:2)
       at android.os.Handler.handleCallback + 873(Handler.java:873)
       at android.os.Handler.dispatchMessage + 99(Handler.java:99)
       at android.os.Looper.loop + 214(Looper.java:214)
       at android.app.ActivityThread.main + 7073(ActivityThread.java:7073)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 494(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main + 965(ZygoteInit.java:965)
gwhelanLD commented 4 years ago

Hi @tanmaythakar4,

As this is not a ConcurrentModificationException, I believe your issue is unrelated to this issue. Would you try and replicate on the most recent SDK version (2.12.0)? If you continue to run into this exception please open a github new issue so we can address it.

Thanks, @gwhelanLD