camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] camel git commit: CAMEL-8177: Graceful shutdown - Should allow background thread to terminate
Date Wed, 24 Dec 2014 11:14:53 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 4dd8545f6 -> 44730ce0c
  refs/heads/camel-2.14.x c1bba088c -> 2c454a3ad
  refs/heads/master 4b8febaba -> 28b49e84e


CAMEL-8177: Graceful shutdown - Should allow background thread to terminate


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/28b49e84
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/28b49e84
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/28b49e84

Branch: refs/heads/master
Commit: 28b49e84e01a65b9eb8482218a355062378b6038
Parents: 4b8feba
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Dec 24 11:01:35 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Dec 24 11:41:10 2014 +0100

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultExecutorServiceManager.java   | 2 +-
 .../java/org/apache/camel/impl/DefaultShutdownStrategy.java    | 3 ++-
 .../java/org/apache/camel/impl/DefaultThreadPoolFactory.java   | 6 +++---
 .../camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java       | 4 ++--
 4 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/28b49e84/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
b/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
index b86e091..491d950 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultExecutorServiceManager.java
@@ -200,7 +200,7 @@ public class DefaultExecutorServiceManager extends ServiceSupport implements
Exe
         ThreadPoolProfile profile = new ThreadPoolProfile(name);
         profile.setPoolSize(poolSize);
         profile.setMaxPoolSize(maxPoolSize);
-        return  newThreadPool(source, name, profile);
+        return newThreadPool(source, name, profile);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/28b49e84/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
index def82f7..a7a363d 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
@@ -367,7 +367,8 @@ public class DefaultShutdownStrategy extends ServiceSupport implements
ShutdownS
 
     private ExecutorService getExecutorService() {
         if (executor == null) {
-            executor = camelContext.getExecutorServiceManager().newSingleThreadExecutor(this,
"ShutdownTask");
+            // use a thread pool that allow to terminate idle threads so they do not hang
around forever
+            executor = camelContext.getExecutorServiceManager().newThreadPool(this, "ShutdownTask",
0, 1);
         }
         return executor;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/28b49e84/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
b/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
index 89eafeb..dd0c639 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultThreadPoolFactory.java
@@ -58,9 +58,9 @@ public class DefaultThreadPoolFactory implements ThreadPoolFactory {
                                          int maxQueueSize, RejectedExecutionHandler rejectedExecutionHandler,
                                          ThreadFactory threadFactory) throws IllegalArgumentException
{
 
-        // the core pool size must be higher than 0
-        if (corePoolSize < 1) {
-            throw new IllegalArgumentException("CorePoolSize must be >= 1, was " + corePoolSize);
+        // the core pool size must be 0 or higher
+        if (corePoolSize < 0) {
+            throw new IllegalArgumentException("CorePoolSize must be >= 0, was " + corePoolSize);
         }
 
         // validate max >= core

http://git-wip-us.apache.org/repos/asf/camel/blob/28b49e84/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
b/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
index 7c79941..9b3ddd7 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
@@ -40,8 +40,8 @@ public class ThreadsZeroInCoreAndMaxPoolTest extends ContextTestSupport
{
                 @Override
                 public void configure() throws Exception {
                     from("direct:start")
-                    // will use a a custom thread pool with 0 in core and 2 max
-                        .threads(0, 2).to("mock:result");
+                    // will use a a custom thread pool with -1 in core and 2 max
+                        .threads(-1, 2).to("mock:result");
                 }
             });
             fail("Expect FailedToCreateRouteException exception here");


Mime
View raw message