[ 
https://issues.apache.org/jira/browse/CURATOR-557?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17023731#comment-17023731
 ] 

Shay Shimony commented on CURATOR-557:
--------------------------------------

Thinking about it again, it won't be easy to use the 
CloseableExecutorService.awaitTermination, because it is an internal component 
of the service provider. 
CloseableExecutorService is wrapped by PathChildrenCache which is wrapped by 
ServiceCacheImpl which is wrapped by ServiceProviderImpl. We would need to add 
each one of them awaitTermination.

I suggest to leave the CloseableExecutorService.close() method as it is (no 
call to ExecutorService.awaitTermination from there), and in case that the 
users want to do ThreadExecutor.awaitTermination then they should create their 
own ExecutorService and build the ServiceProviderImpl upon it (using your new 
API in ServiceProviderBuilder). Thus, after calling close() on the service 
provider the users still have control and can call ExecutorService.shutdownNow 
and awaitTermination however they want.

In my opinion, the users should use the ThreadFactory only if they don't need 
to await the termination of threads. If they do need, they still can get back 
the control as mentioned.

We still need 1 and 3.

> ServiceCacheImpl does not close ExecutorService
> -----------------------------------------------
>
>                 Key: CURATOR-557
>                 URL: https://issues.apache.org/jira/browse/CURATOR-557
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 4.2.0
>            Reporter: Roelof Naude
>            Priority: Major
>         Attachments: CURATOR-557.patch
>
>
> ServiceCacheImpl does not close the ExecutorService instance created from the 
> ThreadFactory:
> [https://github.com/apache/curator/blob/master/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/details/ServiceCacheImpl.java#L64]
>  
> CloseableExecutorService::CloseableExecutorService(ExecutorService) call 
> this(executorService, false) which sets shutdownOnClose to false. 
>  
> this has an impact from callers, eg ServiceProviderImpl, which only allow 
> only a ThreadFactory to be specified.
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to