On 05/01/2025 10:20, Fabian Meumertzheim wrote:
Hi,
I recently traced a race in an application
(https://github.com/bazelbuild/bazel/issues/21773) down to a
particular behavior of ExecutorService#close that, to me, doesn't seem
to be obvious from its documentation: If a task that has been
submitted to the executor is canceled while it is already executing,
ExecutorService#close will not wait for the associated Runnable to
return.
Thanks for bringing this up. TPTE interpreted "all tasks have completed
execution" to mean all tasks done (Future::isDone) whereas it may have
been better to have followed TPE and FJP and wait for all threads to
have completed the tasks. So yes, some spec clarification may be needed
here but it will need to take into account other ExecutorService
implementation that may exist elsewhere. In addition, we need to think
about changing TPTE to avoid the surprising behavior.
-Alan