Client should not shutdown provided executor
Description
#1844 introduced a new API that allowed creating Clients with an external Executor. Multiple Clients can now share the same executor. However, when a Client is closed it shuts down its executor no matter whether it was provided or created by the client itself. That affects multiple clients sharing the same executor, reusing the executor for a client that had to be restarted, and lots of other scenarios where users assume control over their executor.
Steps to reproduce
- Create two Clients with the same external executor
- Close one Client
- Continue using the second Client
Additional context
No response
Hedera network
other
Version
2.39.0
Operating system
Linux
Hi Oleg, you could use client.closeChannels();, which will not shutdown the executor.
This is counterintuitive from the API point of view and I expect every developer to fall for it. I'll update my client code as suggested. However, the point that SDK should not close user provided executor is still valid.
@0xivanov would a solution be to track if the executor was user-provided or not, and in the former case, do not close it?
@steffenboe Yes, we could do that. If you feel like doing this, I don't have any problems with that.