ThreadExecutorTest.testInvokeAnyInterrupt1 random failure
Alan Bateman
Alan.Bateman at oracle.com
Thu Aug 27 11:28:01 UTC 2020
On 27/08/2020 03:51, kalinshi(施慧) wrote:
> Hi all,
>
> Checking testInvokeAnyInterrupt1 test in ThreadExecutorTest.java it might have random failure in some executing orders. In most times execution performs in following order
>
> 1. set kernel thread interrupted
>
> 2. submit first task in AbstractExecutorService.doInvokeAny
>
> 3. poll ExecutorCompletionService. completionQueue which is empty in most cases and return null
>
> 4. submit second task in AbstractExecutorService.doInvokeAny loop
>
> 5. poll again and still no task completed
>
> 6. No task to submit and block kernel thread in ExecutorCompletionService.take, because kernel thread is interrupted, it throws InterruptedException
>
> But in real world, task might finished before poll in step3/step5, then kernel thread has no chance to block in ExecutorCompletionService.take and return without InterruptedException.
> Suggest task1 and task2 perform sleep long enough to ensure ExecutorCompletionService.poll never returns none null value in this test?
>
The ExecutorService used by this test is not an AbstractExecutorService
so you shouldn't see AbstractExecutorService.doInvokeAny or usages of
ExecutorCompletionService. Instead it will be using
ThreadExecutor.invokeAny which checks the interrupt status before it
looking for the first result. Point taken that the test assumes that the
interrupt status is eagerly checked but I don't immediately see how it
could be failing. Are you sure that it triggers the assert at L322
because invokeAny returns will a result?
-Alan
More information about the loom-dev
mailing list