回复: ThreadExecutorTest.testInvokeAnyInterrupt1 random failure(Internet mail)

kalinshi(施慧) kalinshi at tencent.com
Fri Aug 28 01:56:54 UTC 2020


Thanks for pointing out reason why if fail with AbstractExecutorService.doInvokeAny! 

Got random failure when replacing scheduler, previous I was assume ExecutorServices's behavior is same for invokeAny method.
Regards!
Hui

-----邮件原件-----
发件人: Alan Bateman <Alan.Bateman at oracle.com> 
发送时间: 2020年8月27日 19:28
收件人: kalinshi(施慧) <kalinshi at tencent.com>; loom-dev at openjdk.java.net
主题: Re: ThreadExecutorTest.testInvokeAnyInterrupt1 random failure(Internet mail)

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