Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Shutdown is not deterministic - race condition in ExecutorService shutdown #524

Copy link
Copy link
@Mahoney

Description

@Mahoney
Issue body actions

We're using the analytics client in our tests as so:

// before test
val analytics: Analytics = Analytics
  .builder(writeKey.value)
  .endpoint(wireMockUrl.toASCIIString())
  .build()

// during test
val message = TrackMessage
      .builder("my-event-name")

analytics.enqueue(message)

// before asserting anything
analytics.flush()
analytics.shutdown()

with a mock HTTP client that just gathers all requests.

We are seeing our tests be flaky because sometimes that message never hits the mock server.

Looking at AnalyticsClient.java I'm pretty sure it's possible for the call to AnalyticsClient.shutdown() to shutdown the networkExecutor before the looper has submitted the last batch to it; you never interrogate the Future<?> returned when you call looperExecutor.submit(new Looper()) so the RejectedExecutionException thrown when Looper calls networkExecutor.submit(BatchUploadTask) after the networkExecutor has been shutdown is silently swallowed.

Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.