Repository: camel Updated Branches: refs/heads/camel-2.13.x 72e8ede12 -> acb11019f
CAMEL-8094: Do not use org.jboss.netty.util.internal.ExecutorUtil as it breaks the camel-netty Karaf feature Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/acb11019 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/acb11019 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/acb11019 Branch: refs/heads/camel-2.13.x Commit: acb11019fe03339fde151ff4f01e69a5f65cb4e9 Parents: 72e8ede Author: Babak Vahdat <bvah...@apache.org> Authored: Sun Nov 30 12:06:09 2014 +0100 Committer: Babak Vahdat <bvah...@apache.org> Committed: Sun Nov 30 12:11:23 2014 +0100 ---------------------------------------------------------------------- .../netty/NettyClientBossPoolBuilder.java | 16 ----------- .../camel/component/netty/NettyProducer.java | 14 +++++++--- .../netty/NettyServerBossPoolBuilder.java | 18 +------------ .../component/netty/NettyWorkerPoolBuilder.java | 28 +------------------- 4 files changed, 13 insertions(+), 63 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/acb11019/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java ---------------------------------------------------------------------- diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java index 46cd768..6025840 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java @@ -23,7 +23,6 @@ import org.jboss.netty.channel.socket.nio.BossPool; import org.jboss.netty.channel.socket.nio.NioClientBossPool; import org.jboss.netty.util.ThreadNameDeterminer; import org.jboss.netty.util.Timer; -import org.jboss.netty.util.internal.ExecutorUtil; /** * A builder to create Netty {@link org.jboss.netty.channel.socket.nio.BossPool} which can be used for sharing boos pools @@ -78,19 +77,4 @@ public final class NettyClientBossPoolBuilder { BossPool build() { return new NioClientBossPool(Executors.newCachedThreadPool(), bossCount, timer, new CamelNettyThreadNameDeterminer(pattern, name)); } - - class CamelNioClientBossPool extends NioClientBossPool { - private Executor executor; - CamelNioClientBossPool(Executor bossExecutor, int bossCount, Timer timer, ThreadNameDeterminer determiner) { - super(bossExecutor, bossCount, timer, determiner); - executor = bossExecutor; - } - - // Just make sure we shutdown the executor; - public void shutdown() { - super.shutdown(); - ExecutorUtil.shutdownNow(executor); - } - - } } http://git-wip-us.apache.org/repos/asf/camel/blob/acb11019/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java index 5e19763..a173781 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java @@ -51,6 +51,7 @@ import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory; import org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool; import org.jboss.netty.channel.socket.nio.WorkerPool; +import org.jboss.netty.util.ExternalResourceReleasable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,7 +161,12 @@ public class NettyProducer extends DefaultAsyncProducer { bossPool = null; } if (workerPool != null) { - workerPool.shutdown(); + if (workerPool instanceof ExternalResourceReleasable) { + // this will first invoke workerPool#shutdown() internally (e.g. org.jboss.netty.channel.socket.nio.AbstractNioWorkerPool) + ((ExternalResourceReleasable) workerPool).releaseExternalResources(); + } else { + workerPool.shutdown(); + } workerPool = null; } @@ -173,12 +179,14 @@ public class NettyProducer extends DefaultAsyncProducer { } if (channelFactory != null) { - channelFactory.shutdown(); + // this will first invoke channelFactory#shutdown() internally (see it's javadoc) + channelFactory.releaseExternalResources(); channelFactory = null; } if (datagramChannelFactory != null) { - datagramChannelFactory.shutdown(); + // this will first invoke datagramChannelFactory#shutdown() internally (see it's javadoc) + datagramChannelFactory.releaseExternalResources(); datagramChannelFactory = null; } http://git-wip-us.apache.org/repos/asf/camel/blob/acb11019/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java ---------------------------------------------------------------------- diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java index defac5e..6f45dc2 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java @@ -22,7 +22,6 @@ import java.util.concurrent.Executors; import org.jboss.netty.channel.socket.nio.BossPool; import org.jboss.netty.channel.socket.nio.NioServerBossPool; import org.jboss.netty.util.ThreadNameDeterminer; -import org.jboss.netty.util.internal.ExecutorUtil; /** * A builder to create Netty {@link org.jboss.netty.channel.socket.nio.BossPool} which can be used for sharing boos pools @@ -65,21 +64,6 @@ public final class NettyServerBossPoolBuilder { * Creates a new boss pool. */ BossPool build() { - return new CamelNioServerBossPool(Executors.newCachedThreadPool(), bossCount, new CamelNettyThreadNameDeterminer(pattern, name)); - } - - class CamelNioServerBossPool extends NioServerBossPool { - private Executor executor; - CamelNioServerBossPool(Executor bossExecutor, int bossCount, ThreadNameDeterminer determiner) { - super(bossExecutor, bossCount, determiner); - executor = bossExecutor; - } - - // Just make sure we shutdown the executor; - public void shutdown() { - super.shutdown(); - ExecutorUtil.shutdownNow(executor); - } - + return new NioServerBossPool(Executors.newCachedThreadPool(), bossCount, new CamelNettyThreadNameDeterminer(pattern, name)); } } http://git-wip-us.apache.org/repos/asf/camel/blob/acb11019/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java ---------------------------------------------------------------------- diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java index 398a4e0..229040d 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java @@ -22,7 +22,6 @@ import java.util.concurrent.Executors; import org.jboss.netty.channel.socket.nio.NioWorkerPool; import org.jboss.netty.channel.socket.nio.WorkerPool; import org.jboss.netty.util.ThreadNameDeterminer; -import org.jboss.netty.util.internal.ExecutorUtil; /** * A builder to create Netty {@link WorkerPool} which can be used for sharing worker pools @@ -67,32 +66,7 @@ public final class NettyWorkerPoolBuilder { */ WorkerPool build() { int count = workerCount > 0 ? workerCount : NettyHelper.DEFAULT_IO_THREADS; - workerPool = new CamelNioWorkerPool(Executors.newCachedThreadPool(), count, new CamelNettyThreadNameDeterminer(pattern, name)); + workerPool = new NioWorkerPool(Executors.newCachedThreadPool(), count, new CamelNettyThreadNameDeterminer(pattern, name)); return workerPool; } - - class CamelNioWorkerPool extends NioWorkerPool { - private Executor executor; - CamelNioWorkerPool(Executor workerExecutor, int count, ThreadNameDeterminer determiner) { - super(workerExecutor, count, determiner); - executor = workerExecutor; - } - - // Just make sure we shutdown the executor; - public void shutdown() { - super.shutdown(); - ExecutorUtil.shutdownNow(executor); - } - - } - - /** - * Shutdown the created worker pool - */ - public void destroy() { - if (workerPool != null) { - workerPool.shutdown(); - workerPool = null; - } - } }