aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-06-14 15:35:31 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-15 08:37:31 +0000
commit4352dd23ba08357349df321a98bc2546d4094415 (patch)
treec4cbe620b6e42facde879f867b15ffb7b74fa5fd /src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
parentadae32a636d05c02d116fc944faa672a8d980415 (diff)
Remove ability of AbstractQueueVisitor to continue after an interrupt. That functionality was only used in tests.
-- MOS_MIGRATED_REVID=124841573
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java b/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
index 7c751fce36..c22f5eb68a 100644
--- a/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/concurrent/AbstractQueueVisitorTest.java
@@ -229,7 +229,7 @@ public class AbstractQueueVisitorTest {
executor.awaitTermination(TestUtils.WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
- private void assertInterruptWorkers(ThreadPoolExecutor executor) throws Exception {
+ private static void assertInterruptWorkers(ThreadPoolExecutor executor) throws Exception {
final CountDownLatch latch1 = new CountDownLatch(1);
final CountDownLatch latch2 = new CountDownLatch(1);
final boolean[] workerThreadInterrupted = { false };
@@ -266,14 +266,13 @@ public class AbstractQueueVisitorTest {
@Test
public void failFast() throws Exception {
// In failFast mode, we only run actions queued before the exception.
- assertFailFast(null, true, false, false, "a", "b");
+ assertFailFast(null, true, false, "a", "b");
// In !failFast mode, we complete all queued actions.
- assertFailFast(null, false, false, false, "a", "b", "1", "2");
+ assertFailFast(null, false, false, "a", "b", "1", "2");
// Now check fail-fast on interrupt:
- assertFailFast(null, false, true, true, "a", "b");
- assertFailFast(null, false, false, true, "a", "b", "1", "2");
+ assertFailFast(null, false, true, "a", "b");
}
@Test
@@ -281,26 +280,29 @@ public class AbstractQueueVisitorTest {
ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());
// In failFast mode, we only run actions queued before the exception.
- assertFailFast(executor, true, false, false, "a", "b");
+ assertFailFast(executor, true, false, "a", "b");
// In !failFast mode, we complete all queued actions.
- assertFailFast(executor, false, false, false, "a", "b", "1", "2");
+ assertFailFast(executor, false, false, "a", "b", "1", "2");
// Now check fail-fast on interrupt:
- assertFailFast(executor, false, true, true, "a", "b");
- assertFailFast(executor, false, false, true, "a", "b", "1", "2");
+ assertFailFast(executor, false, true, "a", "b");
executor.shutdown();
assertTrue(executor.awaitTermination(TestUtils.WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS));
}
- private void assertFailFast(ThreadPoolExecutor executor,
- boolean failFastOnException, boolean failFastOnInterrupt,
- boolean interrupt, String... expectedVisited) throws Exception {
+ private static void assertFailFast(
+ ThreadPoolExecutor executor,
+ boolean failFastOnException,
+ boolean interrupt,
+ String... expectedVisited)
+ throws Exception {
assertTrue(executor == null || !executor.isShutdown());
- AbstractQueueVisitor visitor = (executor == null)
- ? new ConcreteQueueVisitor(failFastOnException, failFastOnInterrupt)
- : new ConcreteQueueVisitor(executor, failFastOnException, failFastOnInterrupt);
+ AbstractQueueVisitor visitor =
+ (executor == null)
+ ? new ConcreteQueueVisitor(failFastOnException)
+ : new ConcreteQueueVisitor(executor, failFastOnException);
List<String> visitedList = Collections.synchronizedList(Lists.<String>newArrayList());
@@ -457,7 +459,7 @@ public class AbstractQueueVisitorTest {
assertTrue(criticalErrorSeen.get());
}
- private Runnable throwingRunnable() {
+ private static Runnable throwingRunnable() {
return new Runnable() {
@Override
public void run() {
@@ -466,7 +468,7 @@ public class AbstractQueueVisitorTest {
};
}
- private Runnable interruptingRunnable(final Thread thread) {
+ private static Runnable interruptingRunnable(final Thread thread) {
return new Runnable() {
@Override
public void run() {
@@ -517,7 +519,7 @@ public class AbstractQueueVisitorTest {
}
public CountingQueueVisitor(ThreadPoolExecutor executor) {
- super(executor, false, true, true);
+ super(executor, false, true);
}
public void enqueue() {
@@ -548,17 +550,12 @@ public class AbstractQueueVisitorTest {
super(5, 3L, TimeUnit.SECONDS, THREAD_NAME);
}
- public ConcreteQueueVisitor(boolean failFast, boolean failFastOnInterrupt) {
- super(true, 5, 3L, TimeUnit.SECONDS, failFast, failFastOnInterrupt, THREAD_NAME);
- }
-
- public ConcreteQueueVisitor(ThreadPoolExecutor executor, boolean failFast,
- boolean failFastOnInterrupt) {
- super(executor, /*shutdownOnCompletion=*/false, failFast, failFastOnInterrupt);
+ public ConcreteQueueVisitor(boolean failFast) {
+ super(true, 5, 3L, TimeUnit.SECONDS, failFast, THREAD_NAME);
}
public ConcreteQueueVisitor(ThreadPoolExecutor executor, boolean failFast) {
- super(executor, /*shutdownOnCompletion=*/false, failFast, true);
+ super(executor, /*shutdownOnCompletion=*/ false, failFast);
}
}
@@ -570,7 +567,6 @@ public class AbstractQueueVisitorTest {
executor,
/*shutdownOnCompletion=*/ true,
/*failFastOnException=*/ false,
- /*failFastOnInterrupt=*/ true,
new ErrorClassifier() {
@Override
protected ErrorClassification classifyException(Exception e) {