Skip to content

Conversation

@neelkanth-kaushik
Copy link
Contributor

@neelkanth-kaushik neelkanth-kaushik commented Nov 17, 2025

This PR patches the Github issue #524

This pull request improves the shutdown process for the AnalyticsClient by ensuring that all messages are properly processed before shutting down executors. The changes address a potential race condition during shutdown and add better error handling for task submission failures.

Shutdown process improvements:

  • Introduced a Future<?> looperFuture to track the completion of the Looper thread, allowing the shutdown process to wait for the looper to finish processing all messages before shutting down executors. This prevents a race condition where the network executor could be shut down before all batches are submitted.
  • Added a waitForLooperCompletion() method that waits (with timeout) for the looper to finish, logs completion or errors, and cancels the looper if it takes too long.

Error handling enhancements:

  • Wrapped network batch submission in a try-catch block to handle RejectedExecutionException during shutdown, logging the error and notifying callbacks of the failure if the batch cannot be submitted.

Dependency updates:

  • Added imports for Future and RejectedExecutionException to support the new shutdown and error handling logic.

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

Successfully merging this pull request may close these issues.

2 participants