Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2016-02-01 11:18:42 -0500
committerGreg Wilkins2016-02-01 11:18:42 -0500
commit7ec6e2e899c5c9fa2aa136cb321892682fcba5dd (patch)
tree09608e925431889791c5e825a54f79a6109f823d
parentc81dcfc79059b6e0a3a0bfd22cb5b5633dd3291b (diff)
downloadorg.eclipse.jetty.project-7ec6e2e899c5c9fa2aa136cb321892682fcba5dd.tar.gz
org.eclipse.jetty.project-7ec6e2e899c5c9fa2aa136cb321892682fcba5dd.tar.xz
org.eclipse.jetty.project-7ec6e2e899c5c9fa2aa136cb321892682fcba5dd.zip
486930 - Selector does not correctly handle rejected execution exception
Improved comments and unit test
-rw-r--r--jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java36
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java3
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java2
3 files changed, 38 insertions, 3 deletions
diff --git a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java
index de4a5d2eb7..c6753c5b03 100644
--- a/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java
+++ b/jetty-io/src/test/java/org/eclipse/jetty/io/SelectChannelEndPointTest.java
@@ -777,11 +777,45 @@ public class SelectChannelEndPointTest
}.start();
}
+ // unblock the handling
latch.countDown();
+
+ // wait for all clients to complete or fail
closed.await();
+
+ // assert some clients must have been rejected
Assert.assertThat(rejections.get(),Matchers.greaterThan(0));
+ // but not all of them
Assert.assertThat(rejections.get(),Matchers.lessThan(10));
+ // none should have timed out
Assert.assertThat(timeout.get(),Matchers.equalTo(0));
- Assert.assertThat(echoed.get(),Matchers.equalTo(10-rejections.get()));
+ // and the rest should have worked
+ Assert.assertThat(echoed.get(),Matchers.equalTo(10-rejections.get()));
+
+ // and the selector is still working for new requests
+ try(Socket client = newClient();)
+ {
+ client.setSoTimeout(5000);
+
+ SocketChannel server = _connector.accept();
+ server.configureBlocking(false);
+
+ _manager.accept(server);
+
+ // Write client to server
+ client.getOutputStream().write("HelloWorld".getBytes(StandardCharsets.UTF_8));
+ client.getOutputStream().flush();
+ client.shutdownOutput();
+
+ // Verify echo server to client
+ for (char c : "HelloWorld".toCharArray())
+ {
+ int b = client.getInputStream().read();
+ assertTrue(b > 0);
+ assertEquals(c, (char)b);
+ }
+ assertEquals(-1,client.getInputStream().read());
+ }
+
}
}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java
index c3436ad35d..4643775e6a 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ExecuteProduceConsume.java
@@ -147,6 +147,7 @@ public class ExecuteProduceConsume implements ExecutionStrategy, Runnable
}
catch(Throwable e)
{
+ // just warn if lowresources execute fails and keep producing
LOG.warn(e);
}
}
@@ -218,7 +219,7 @@ public class ExecuteProduceConsume implements ExecutionStrategy, Runnable
}
catch(RejectedExecutionException e)
{
- // If we cannot execute, the close or discard the task and keep producing
+ // If we cannot execute, then discard/reject the task and keep producing
LOG.debug(e);
LOG.warn("RejectedExecution {}",task);
try
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java
index 6e7c95e571..9310c05d5f 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/strategy/ProduceExecuteConsume.java
@@ -62,7 +62,7 @@ public class ProduceExecuteConsume implements ExecutionStrategy
}
catch(RejectedExecutionException e)
{
- // Close or discard tasks that cannot be executed
+ // Discard/reject tasks that cannot be executed
if (task instanceof Rejectable)
{
try

Back to the top