You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by he...@apache.org on 2015/03/06 12:13:01 UTC

camel git commit: [CAMEL-8450] Netty component should not stop/null static timer when stopping

Repository: camel
Updated Branches:
  refs/heads/master 066ab818b -> 72c65431b


[CAMEL-8450] Netty component should not stop/null static timer when stopping


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

Branch: refs/heads/master
Commit: 72c65431b0dc0c5df847fc4ce628e50794cb8934
Parents: 066ab81
Author: Henryk Konsek <he...@gmail.com>
Authored: Fri Mar 6 12:12:54 2015 +0100
Committer: Henryk Konsek <he...@gmail.com>
Committed: Fri Mar 6 12:12:54 2015 +0100

----------------------------------------------------------------------
 .../camel/component/netty/NettyComponent.java   |  3 --
 .../netty/NettyConcurrentTimerAccessTest.java   | 52 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/72c65431/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
index 3954e2e..b140cba 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyComponent.java
@@ -146,9 +146,6 @@ public class NettyComponent extends UriEndpointComponent {
 
     @Override
     protected void doStop() throws Exception {
-        timer.stop();
-        timer = null;
-
         if (executorService != null) {
             getCamelContext().getExecutorServiceManager().shutdownNow(executorService);
             executorService = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/72c65431/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTimerAccessTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTimerAccessTest.java b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTimerAccessTest.java
new file mode 100644
index 0000000..e3355e3
--- /dev/null
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTimerAccessTest.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.Test;
+
+public class NettyConcurrentTimerAccessTest extends BaseNettyTest {
+
+    int secondPort = AvailablePortFinder.getNextAvailable(25000);
+
+    @Test
+    public void stoppingOneComponentShouldNotAffectTheOther() throws Exception {
+        context.getComponent("netty1", NettyComponent.class).stop();
+        template.sendBody("netty2:tcp://localhost:" + secondPort + "/pleaseCreateNewEndpoint", "msg");
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("netty1", new NettyComponent());
+        registry.bind("netty2", new NettyComponent());
+        return registry;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("netty1:tcp://localhost:{{port}}").to("mock:test");
+                from("netty2:tcp://localhost:" + secondPort).to("mock:test");
+            }
+        };
+    }
+
+}