diff --git a/akka-actor/src/main/scala/akka/dispatch/Dispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/Dispatcher.scala index f6386bef82..2d19f7a518 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Dispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Dispatcher.scala @@ -34,7 +34,6 @@ import akka.actor.ActorSystem * .setCorePoolSize(16) * .setMaxPoolSize(128) * .setKeepAliveTimeInMillis(60000) - * .setRejectionPolicy(new CallerRunsPolicy) * .buildThreadPool * *

@@ -49,7 +48,6 @@ import akka.actor.ActorSystem * .setCorePoolSize(16) * .setMaxPoolSize(128) * .setKeepAliveTimeInMillis(60000) - * .setRejectionPolicy(new CallerRunsPolicy()) * .buildThreadPool(); * *

@@ -123,7 +121,13 @@ class Dispatcher( executorService.get() execute mbox true } catch { - case e: RejectedExecutionException ⇒ executorService.get() execute mbox; true //Retry once + case e: RejectedExecutionException ⇒ + try { + executorService.get() execute mbox + true + } catch { //Retry once + case e: RejectedExecutionException ⇒ mbox.setAsIdle(); throw e + } } } else false } else false diff --git a/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala b/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala index 2797652f77..65eef3821d 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala @@ -22,7 +22,6 @@ import akka.actor.ActorSystem * .setCorePoolSize(16) * .setMaxPoolSize(128) * .setKeepAliveTimeInMillis(60000) - * .setRejectionPolicy(new CallerRunsPolicy) * .build * *

@@ -36,7 +35,6 @@ import akka.actor.ActorSystem * .setCorePoolSize(16) * .setMaxPoolSize(128) * .setKeepAliveTimeInMillis(60000) - * .setRejectionPolicy(new CallerRunsPolicy()) * .build(); * *

diff --git a/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala b/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala index 6a9c2c55c4..6cb927a5dd 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala @@ -7,10 +7,10 @@ package akka.dispatch import java.util.Collection import java.util.concurrent._ import atomic.{ AtomicLong, AtomicInteger } -import ThreadPoolExecutor.CallerRunsPolicy import akka.util.Duration import akka.event.Logging.{ Warning, Error } import akka.actor.ActorSystem +import java.util.concurrent.ThreadPoolExecutor.{ AbortPolicy } object ThreadPoolConfig { type Bounds = Int @@ -21,7 +21,7 @@ object ThreadPoolConfig { val defaultCorePoolSize: Int = 16 val defaultMaxPoolSize: Int = 128 val defaultTimeout: Duration = Duration(60000L, TimeUnit.MILLISECONDS) - def defaultFlowHandler: FlowHandler = flowHandler(new CallerRunsPolicy) + def defaultFlowHandler: FlowHandler = flowHandler(new AbortPolicy) def flowHandler(rejectionHandler: RejectedExecutionHandler): FlowHandler = Left(rejectionHandler) def flowHandler(bounds: Int): FlowHandler = Right(bounds) diff --git a/config/akka-reference.conf b/config/akka-reference.conf index 0aa5a8d8b3..6abc7cc91c 100644 --- a/config/akka-reference.conf +++ b/config/akka-reference.conf @@ -32,7 +32,7 @@ akka { task-queue-size = -1 # Specifies the bounded capacity of the task queue (< 1 == unbounded) task-queue-type = "linked" # Specifies which type of task queue will be used, can be "array" or "linked" (default) allow-core-timeout = on # Allow core threads to time out - rejection-policy = "caller-runs" # abort, caller-runs, discard-oldest, discard + rejection-policy = "abort" # abort, caller-runs, discard-oldest, discard throughput = 5 # Throughput for Dispatcher, set to 1 for complete fairness throughput-deadline-time = -1 # Throughput deadline for Dispatcher, set to 0 or negative for no deadline mailbox-capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default) @@ -128,7 +128,7 @@ akka { task-queue-size = -1 # Specifies the bounded capacity of the task queue (< 1 == unbounded) task-queue-type = "linked" # Specifies which type of task queue will be used, can be "array" or "linked" (default) allow-core-timeout = on # Allow core threads to time out - rejection-policy = "caller-runs" # abort, caller-runs, discard-oldest, discard + rejection-policy = "abort" # abort, caller-runs, discard-oldest, discard throughput = 5 # Throughput for Dispatcher, set to 1 for complete fairness throughput-deadline-time = -1 # Throughput deadline for Dispatcher, set to 0 or negative for no deadline mailbox-capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)