[CURATOR-469] Give background task a chance to execute in CuratorFramework.close()
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
The current impl of CuratorFramework.close() does not really give background task a chance to finish. The following steps are currently taken in close().
1. Set the state to STOPPED
2. Call executorService.shutdownNow();
3. Call executorService.awaitTermination(maxCloseWaitMs, TimeUnit.MILLISECONDS);
After step 1 is complete any background task accessing curator will get an IllegalStateException (See CURATOR-467). Step 2 interrupts actively running task and dequeues any task waiting run. In step 3 I wonder why bother to wait?
Making close do the following is one possible way to give background task a chance to run.
1. Call executorService.shutdown();
2. Call executorService.awaitTermination(maxCloseWaitMs, TimeUnit.MILLISECONDS);
3. Set the state to STOPPED
4. Call executorService.shutdownNow();
Step 1 prevents new task from being added, but gives currently running and queued task a chance. In step 2 we wait up to the user configured time for task to complete. In step 3 and 4 we cause any background task that are still running to fail.
---
Originally reported by kturner, imported from: Give background task a chance to execute in CuratorFramework.close()
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.