spring-cloud/spring-cloud-sleuth

`TraceableExecutorService` does not terminate tests when wrapping the `ForkJoinPool.commonPool()`

TheBestPessimist opened this issue · 3 comments

Describe the bug
When wrapping ForkJoinPool.commonPool() and running tests, the tests do not finish because the pool does not shut down.

sample code:

@Configuration
class CaffeineExecutorFactory {
	@Bean("caffeineExecutor")
	fun caffeineExecutor(beanFactory: BeanFactory): ExecutorService {
		println("created")
        return TraceableExecutorService.wrap(beanFactory, ForkJoinPool.commonPool()) // ❌ when running the tests, the tests do not finish because the pull does not shut down
	}
}

It seems we're stuck inside TraceableExecutorService.close, because ForkJoinPool.awaitTermination always returns false.
image

Sample
demo.zip

Are you sure that the executor's shutdown method is being called?

i dont know that/don't remember. i decided the easiest sollution is to use another thread pool (cached thread pool) and not the common FJP one. I remember retrying the FJP again sometime in november and the bug was still there.
I'm not working on this project anymore though.

Thanks for the update