fix query cancellation test race condition

This commit is contained in:
Xavier Léauté 2014-06-13 11:28:48 -07:00
parent b2419b1530
commit 4c4047165f
1 changed files with 6 additions and 1 deletions

View File

@ -243,7 +243,9 @@ public class ChainedExecutionQueryRunnerTest
Assert.assertTrue(future.isCancelled());
Assert.assertTrue(runner1.hasStarted);
Assert.assertTrue(runner2.hasStarted);
Assert.assertFalse(runner3.hasStarted);
Assert.assertTrue(runner1.interrupted);
Assert.assertTrue(runner2.interrupted);
Assert.assertTrue(!runner3.hasStarted || runner3.interrupted);
Assert.assertFalse(runner1.hasCompleted);
Assert.assertFalse(runner2.hasCompleted);
Assert.assertFalse(runner3.hasCompleted);
@ -256,6 +258,7 @@ public class ChainedExecutionQueryRunnerTest
private final CountDownLatch latch;
private boolean hasStarted = false;
private boolean hasCompleted = false;
private boolean interrupted = false;
public DyingQueryRunner(CountDownLatch latch)
{
@ -268,6 +271,7 @@ public class ChainedExecutionQueryRunnerTest
hasStarted = true;
latch.countDown();
if (Thread.interrupted()) {
interrupted = true;
throw new QueryInterruptedException("I got killed");
}
@ -276,6 +280,7 @@ public class ChainedExecutionQueryRunnerTest
Thread.sleep(500);
}
catch (InterruptedException e) {
interrupted = true;
throw new QueryInterruptedException("I got killed");
}