In short, the root cause is that Watchdog.shutdown and Watchdog.isShutdown should have consistent behavior, but we also need to decide if we want Watchdog to manage the Executor or not.
There are three possible approaches:
This PR. Watchdog still manages its own executor on shutdown and shouldAutoClose is the source of truth to decide if we want to shutdown executor or not, have to expose a new interface(not breaking since we can add it as a default) in WatchdogProvider to set shouldAutoClose. This is my preferred approach since I think it's the cleanest one and still provides the ability to auto close the executors provided to Watchdog.
https://github.com/googleapis/gax-java/pull/1883. Watchdog still manages its own executor on shutdown, but we use both shouldAutoClose and needExecutor to decide if we want to shutdown executor or not.
This PR is an attempt to fix https://github.com/googleapis/gax-java/issues/1858. Note that the issue above is just the behavior of multiple convoluted issues. The background is as below:
shutdown
https://github.com/googleapis/gax-java/pull/871shutdownNow
https://github.com/googleapis/gax-java/pull/1158In short, the root cause is that
Watchdog.shutdown
andWatchdog.isShutdown
should have consistent behavior, but we also need to decide if we want Watchdog to manage the Executor or not.There are three possible approaches:
shouldAutoClose
is the source of truth to decide if we want to shutdown executor or not, have to expose a new interface(not breaking since we can add it as a default) inWatchdogProvider
to setshouldAutoClose
. This is my preferred approach since I think it's the cleanest one and still provides the ability to auto close the executors provided to Watchdog.shouldAutoClose
andneedExecutor
to decide if we want to shutdown executor or not.