You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/04/20 16:49:33 UTC

[4/4] git commit: CAMEL-7379 fixed the issue of allChannels should not be static variable for the NettyProducer

CAMEL-7379 fixed the issue of allChannels should not be static variable for the NettyProducer


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

Branch: refs/heads/camel-2.12.x
Commit: b24356493740260f1685af39e2ce0f794adf69ac
Parents: 935d947
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Apr 20 22:39:59 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Apr 20 22:49:07 2014 +0800

----------------------------------------------------------------------
 .../apache/camel/component/netty/NettyProducer.java   | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b2435649/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 1b0a7a7..9e318d3 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
@@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory;
 
 public class NettyProducer extends DefaultAsyncProducer {
     private static final Logger LOG = LoggerFactory.getLogger(NettyProducer.class);
-    private static final ChannelGroup ALL_CHANNELS = new DefaultChannelGroup("NettyProducer");
+    private final ChannelGroup allChannels = new DefaultChannelGroup("NettyProducer");
     private CamelContext context;
     private NettyConfiguration configuration;
     private ChannelFactory channelFactory;
@@ -148,8 +148,8 @@ public class NettyProducer extends DefaultAsyncProducer {
     protected void doStop() throws Exception {
         LOG.debug("Stopping producer at address: {}", configuration.getAddress());
         // close all channels
-        LOG.trace("Closing {} channels", ALL_CHANNELS.size());
-        ChannelGroupFuture future = ALL_CHANNELS.close();
+        LOG.trace("Closing {} channels", allChannels.size());
+        ChannelGroupFuture future = allChannels.close();
         future.awaitUninterruptibly();
 
         // and then release other resources
@@ -400,7 +400,7 @@ public class NettyProducer extends DefaultAsyncProducer {
             connectionlessClientBootstrap.setPipelineFactory(pipelineFactory);
             // bind and store channel so we can close it when stopping
             Channel channel = connectionlessClientBootstrap.bind(new InetSocketAddress(0));
-            ALL_CHANNELS.add(channel);
+            allChannels.add(channel);
             answer = connectionlessClientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
 
             if (LOG.isDebugEnabled()) {
@@ -442,7 +442,7 @@ public class NettyProducer extends DefaultAsyncProducer {
         }
         Channel answer = channelFuture.getChannel();
         // to keep track of all channels in use
-        ALL_CHANNELS.add(answer);
+        allChannels.add(answer);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Creating connector to address: {}", configuration.getAddress());
@@ -467,7 +467,7 @@ public class NettyProducer extends DefaultAsyncProducer {
     }
 
     public ChannelGroup getAllChannels() {
-        return ALL_CHANNELS;
+        return allChannels;
     }
 
     /**
@@ -515,7 +515,7 @@ public class NettyProducer extends DefaultAsyncProducer {
         public void destroyObject(Channel channel) throws Exception {
             LOG.trace("Destroying channel: {}", channel);
             NettyHelper.close(channel);
-            ALL_CHANNELS.remove(channel);
+            allChannels.remove(channel);
         }
 
         @Override