[
https://issues.apache.org/jira/browse/CURATOR-469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16502650#comment-16502650
]
Cameron McKenzie commented on CURATOR-469:
------------------------------------------
This sounds like a sensible approach, and I think it will fix a number of
issues:
CURATOR-448, CURATOR-467 and CURATOR-468
Would you like to submit a PR for this fix?
> Give background task a chance to execute in CuratorFramework.close()
> --------------------------------------------------------------------
>
> Key: CURATOR-469
> URL: https://issues.apache.org/jira/browse/CURATOR-469
> Project: Apache Curator
> Issue Type: Improvement
> Reporter: Keith Turner
> Assignee: Jordan Zimmerman
> Priority: Major
>
> 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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)