有没有办法杀死所有 AssertJ 创建的固定装置,或者在创建新固定装置时如何防止挂起?在尝试将大量遗留 GUI 测试迁移到 AssertJ Swing 时,我经常不得不面对以下死锁:
"main" #1 prio=5 os_prio=0 tid=0x0000000002080000 nid=0x9c waiting on condition [0x00000000024cd000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000547049720> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at org.assertj.swing.lock.ScreenLock.acquire(ScreenLock.java:57)
at org.assertj.swing.core.BasicRobot.acquireScreenLock(BasicRobot.java:164)
at org.assertj.swing.core.BasicRobot.robotWithCurrentAwtHierarchy(BasicRobot.java:153)
at org.assertj.swing.fixture.AbstractWindowFixture.<init>(AbstractWindowFixture.java:119)
at org.assertj.swing.fixture.FrameFixture.<init>(FrameFixture.java:43)
这当然是由于错误使用灯具造成的,当正在创建一个新的而另一个仍然处于活动状态时。然而,这种僵局使迁移变得复杂。