Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2012-07-12 09:44:53 -0400
committerGlyn Normington2012-07-12 09:44:53 -0400
commit69ac2dd84e2fe80923eca9eaa5802f431379d971 (patch)
treea9a2265dc7211b225563251aec720a3038fb8403 /org.eclipse.virgo.kernel.services
parentd8844ab97466700a61710280c29b14c20b2925fb (diff)
downloadorg.eclipse.virgo.kernel-69ac2dd84e2fe80923eca9eaa5802f431379d971.tar.gz
org.eclipse.virgo.kernel-69ac2dd84e2fe80923eca9eaa5802f431379d971.tar.xz
org.eclipse.virgo.kernel-69ac2dd84e2fe80923eca9eaa5802f431379d971.zip
382688: accommodate change of behaviour of ThreadPoolExecutor.getCompletedTaskCount in Java 7
Diffstat (limited to 'org.eclipse.virgo.kernel.services')
-rw-r--r--org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutor.java17
-rw-r--r--org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutorTests.java25
2 files changed, 13 insertions, 29 deletions
diff --git a/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutor.java b/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutor.java
index cf1d1d4d..fc3c9dea 100644
--- a/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutor.java
+++ b/org.eclipse.virgo.kernel.services/src/main/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutor.java
@@ -21,9 +21,12 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.virgo.kernel.shim.serviceability.TracingService;
-
/**
* Extension of {@link ThreadPoolExecutor} that handles kernel thread decoration.
+ * <p/>
+ * The implementation of ThreadPoolExecutor changed in Java 7 so that getCompletedTaskCount includes tasks that failed
+ * with an exception, unlike Java 6 which excludes such tasks from the count. {@link KernelThreadPoolExecutor} class
+ * inherits this Java version specific behaviour.
*
* <strong>Concurrent Semantics</strong><br/>
*
@@ -45,13 +48,13 @@ public final class KernelThreadPoolExecutor extends ThreadPoolExecutor implement
* @param unit the {@link TimeUnit} for the keep alive time.
* @param workQueue the work queue.
* @param poolName the name of the thread pool.
- * @param tracingService
+ * @param tracingService
*/
- public KernelThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit,
- BlockingQueue<Runnable> workQueue, String poolName, TracingService tracingService) {
+ public KernelThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
+ String poolName, TracingService tracingService) {
this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, poolName, tracingService, null);
}
-
+
/**
* Creates a new <code>ServerThreadPoolExecutor</code>.
*
@@ -64,8 +67,8 @@ public final class KernelThreadPoolExecutor extends ThreadPoolExecutor implement
* @param tracingService the kernel tracing service.
* @param handler the rejected execution handler. May be <code>null</code>.
*/
- public KernelThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit,
- BlockingQueue<Runnable> workQueue, String poolName, TracingService tracingService, RejectedExecutionHandler handler) {
+ public KernelThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
+ String poolName, TracingService tracingService, RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, createThreadFactory(poolName), determineHandler(handler));
this.poolName = poolName;
this.delegate = new ExecutorServiceDelegate(tracingService);
diff --git a/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutorTests.java b/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutorTests.java
index 0562f121..91131665 100644
--- a/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutorTests.java
+++ b/org.eclipse.virgo.kernel.services/src/test/java/org/eclipse/virgo/kernel/services/concurrent/KernelThreadPoolExecutorTests.java
@@ -23,8 +23,10 @@ import org.eclipse.virgo.kernel.services.concurrent.KernelThreadPoolExecutor;
import org.eclipse.virgo.kernel.shim.serviceability.TracingService;
import org.junit.Test;
-
/**
+ * Note that this class used to test the value of getCompletedTaskCount after an execution which failed with an
+ * exception, but the implementation of ThreadPoolExecutor changed in Java 7 so that getCompletedTaskCount included
+ * tasks that failed with an exception. So the test was removed.
*/
public class KernelThreadPoolExecutorTests extends AbstractExecutorTests {
@@ -49,27 +51,6 @@ public class KernelThreadPoolExecutorTests extends AbstractExecutorTests {
}
@Test
- public void statisticsOnFail() throws InterruptedException {
- final CountDownLatch latch = new CountDownLatch(1);
-
- KernelThreadPoolExecutor executor = getExecutor();
- executor.execute(new Runnable() {
-
- public void run() {
- try {
- throw new RuntimeException("foo");
- } finally {
- latch.countDown();
- }
- }
-
- });
- latch.await();
- Thread.sleep(100);
- assertEquals(0, executor.getCompletedTaskCount());
- }
-
- @Test
public void statisticsOnSuccess() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);

Back to the top