lyft / lyft/Kronos-Android

Fatal Exception: java.util.concurrent.RejectedExecutionException

Open
#65 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
287
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Hello, this is a very weird error that happened just once after thousands of tests being done, and cannot replicate, but here is the stacktrace:

```
Fatal Exception: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@398a2b3[Not completed] rejected from java.util.concurrent.ThreadPoolExecutor@3020070[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2072)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:834)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1364)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:671)
at com.lyft.kronos.internal.ntp.SntpServiceImpl.syncInBackground(SntpService.kt:119)
at com.lyft.kronos.internal.ntp.SntpServiceImpl.currentTime(SntpService.kt:109)
at com.lyft.kronos.internal.KronosClockImpl.getCurrentTime(KronosClockImpl.kt:19)
at com.lyft.kronos.KronosClock$DefaultImpls.getCurrentTimeMs(KronosClock.java:39)
at com.lyft.kronos.internal.KronosClockImpl.getCurrentTimeMs(KronosClockImpl.kt:8)
```

It points directly to SntpService.kt:

```
override fun syncInBackground() {
ensureServiceIsRunning()

if (state.get() != State.SYNCING) {
executor.submit { sync() }
}
}
```

Maybe should try/catch for RejectedExecutionException? Cheers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in SntpService.kt at syncInBackground(), then trace ensureServiceIsRunning() and the executor used by the submit call. Use the stack trace to understand how a terminated ThreadPoolExecutor can be reached, and verify that the resulting behavior no longer produces the reported fatal RejectedExecutionException.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.