Skip to content

Occasional RejectedExecutionException is Activity onPause #265

@tevjef

Description

@tevjef

Describe the bug

We occasionally seeing this crash when our Activity pause. In our code if seems to occur when we're in the middle of closing one LDClient and initing another.

Caused by java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@4f892c2 rejected from java.util.concurrent.ScheduledThreadPoolExecutor@e99c8d3[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 8]
       at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2086)
       at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
       at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:334)
       at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:562)
       at java.util.concurrent.Executors$DelegatedScheduledExecutorService.schedule(Executors.java:691)
       at com.launchdarkly.sdk.android.AndroidTaskExecutor.scheduleTask(AndroidTaskExecutor.java:42)
       at com.launchdarkly.sdk.android.AndroidPlatformState$ActivityCallbacks.onActivityPaused(AndroidPlatformState.java:248)
       at android.app.Application.dispatchActivityPaused(Application.java:465)
       at android.app.Activity.dispatchActivityPaused(Activity.java:1473)
       at android.app.Activity.onPause(Activity.java:2426)
       at androidx.fragment.app.FragmentActivity.onPause(FragmentActivity.java:282)
       at com.company.ui.activity.BaseActivity.onPause(BaseActivity.kt:114)
       at android.app.Activity.performPause(Activity.java:8485)
       at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1530)
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:5547)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:5508)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:5460)
       at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:47)
       at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at android.app.ActivityThread.main(ActivityThread.java:8663)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

SDK version
5.1.1

Language version, developer tools
Kotlin 1.9.23
Gradle 8.7
AGP 8.3.2

OS/platform
All versions of Android

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions