RFR: JDK-8229829: java/lang/management/ThreadMXBean/Locks.java fails with java.lang.RuntimeException: Thread WaitingThread is at WAITING state but is expected to be in Thread.State = WAITING

David Holmes david.holmes at oracle.com
Thu May 14 02:20:48 UTC 2020


Hi Alex,

On 14/05/2020 10:55 am, Alex Menkov wrote:
> Hi all,
> 
> Please review the fix for
> https://bugs.openjdk.java.net/browse/JDK-8229829
> webrev:
> http://cr.openjdk.java.net/~amenkov/jdk15/Locks_waiting/webrev/
> 
> The fix adds handling for WAITING

That part is good.

> (and for consistency TIMED_WAITING 

But this could be a problem. I know what your intent is but we are 
waiting to observe a thread transition to a state that it can't escape 
from, but with TIMED_WAITING the thread can escape - when the timeout 
elapses. So it is possible that the target becomes TIMED_WAITING before 
you check the state, but then leaves that state due to timeout, and then 
you check the state and will loop until you trigger a failure.

Cheers,
David
-----

> which is not used in the test) states as it has for BLOCKED state.
> 
> --alex


More information about the serviceability-dev mailing list