You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/12/24 12:14:54 UTC
[2/3] camel git commit: CAMEL-8177: Graceful shutdown - Should allow
background thread to terminate
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/2c454a3a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2c454a3a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2c454a3a
Branch: refs/heads/camel-2.14.x
Commit: 2c454a3ada29ad76dcfa1e82390c789b4d82257f
Parents: c1bba08
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 24 11:01:35 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 24 12:14:24 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/2c454a3a/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/2c454a3a/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/2c454a3a/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/2c454a3a/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");