From c5541cb3bdb62b91a280ae03d0678a6b24c1a194 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 11 Mar 2015 11:02:11 +1100 Subject: [PATCH] 459081 - http2 push failures. Reverted sense of runnable in ExecuteProduceRun so that test harness passes. Added RunExecute Runnable for the new dispatch semantic --- .../thread/strategy/ExecuteProduceRun.java | 15 +++++-------- .../strategy/ExecuteProduceRunTest.java | 22 +++++++++---------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRun.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRun.java index b181e00cfe5..77df766eed9 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRun.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRun.java @@ -45,7 +45,7 @@ public class ExecuteProduceRun implements ExecutionStrategy, Runnable { private static final Logger LOG = Log.getLogger(ExecuteProduceRun.class); private final SpinLock _lock = new SpinLock(); - private final Runnable _resumer = new Resumer(); + private final Runnable _runExecute = new RunExecute(); private final Producer _producer; private final Executor _executor; private boolean _idle=true; @@ -104,16 +104,11 @@ public class ExecuteProduceRun implements ExecutionStrategy, Runnable _execute=true; } if (dispatch) - _executor.execute(this); + _executor.execute(_runExecute); } @Override public void run() - { - execute(); - } - - private void resume() { if (LOG.isDebugEnabled()) LOG.debug("{} run",this); @@ -187,7 +182,7 @@ public class ExecuteProduceRun implements ExecutionStrategy, Runnable // Spawn a new thread to continue production by running the produce loop. if (LOG.isDebugEnabled()) LOG.debug("{} dispatch",this); - _executor.execute(_resumer); + _executor.execute(this); } // Run the task. @@ -234,12 +229,12 @@ public class ExecuteProduceRun implements ExecutionStrategy, Runnable return builder.toString(); } - private class Resumer implements Runnable + private class RunExecute implements Runnable { @Override public void run() { - resume(); + execute(); } } } diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRunTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRunTest.java index c99a7cacf10..ab1df8bac38 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRunTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceRunTest.java @@ -19,7 +19,7 @@ package org.eclipse.jetty.util.thread.strategy; -import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -27,12 +27,10 @@ import java.util.Queue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; -import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.jetty.util.BlockingArrayQueue; import org.eclipse.jetty.util.ConcurrentArrayQueue; import org.eclipse.jetty.util.thread.ExecutionStrategy.Producer; -import org.hamcrest.Matchers; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -100,8 +98,8 @@ public class ExecuteProduceRunTest public void after() { // All done and checked - assertThat(_produce.size(),is(0)); - assertThat(_executions.size(),is(0)); + assertThat(_produce.size(),equalTo(0)); + assertThat(_executions.size(),equalTo(0)); } @Test @@ -118,7 +116,7 @@ public class ExecuteProduceRunTest _produce.add(t0); _produce.add(NULLTASK); _ewyk.execute(); - assertThat(t0.hasRun(),is(true)); + assertThat(t0.hasRun(),equalTo(true)); Assert.assertEquals(_ewyk,_executions.poll()); } @@ -135,7 +133,7 @@ public class ExecuteProduceRunTest _ewyk.execute(); for (int i=0;i