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 2011/11/26 11:02:14 UTC
svn commit: r1206415 - in /camel/branches/camel-2.8.x: ./
camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
Author: davsclaus
Date: Sat Nov 26 10:02:13 2011
New Revision: 1206415
URL: http://svn.apache.org/viewvc?rev=1206415&view=rev
Log:
CAMEL-4696: Fixed issue when removing route causing 2 times shutdown. Thanks to Bilgin for patch.
Modified:
camel/branches/camel-2.8.x/ (props changed)
camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 26 10:02:13 2011
@@ -1 +1 @@
-/camel/trunk:1202148,1202167,1202204-1202206,1202215,1202223,1202659,1202685,1203879,1203978,1204338,1205124,1205372,1205412,1205429,1205431,1205713,1206116
+/camel/trunk:1202148,1202167,1202204-1202206,1202215,1202223,1202659,1202685,1203879,1203978,1204338,1205124,1205372,1205412,1205429,1205431,1205713,1206116,1206414
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1206415&r1=1206414&r2=1206415&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Sat Nov 26 10:02:13 2011
@@ -809,7 +809,6 @@ public class DefaultCamelContext extends
routeService.setRemovingRoutes(true);
shutdownRouteService(routeService);
removeRouteDefinition(routeId);
- ServiceHelper.stopAndShutdownServices(routeService);
routeServices.remove(routeId);
// remove route from startup order as well, as it was removed
Iterator<RouteStartupOrder> it = routeStartupOrder.iterator();
Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java?rev=1206415&r1=1206414&r2=1206415&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java Sat Nov 26 10:02:13 2011
@@ -18,7 +18,6 @@ package org.apache.camel.impl;
import java.util.Collection;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.camel.CamelContext;
@@ -45,7 +44,7 @@ public class DefaultCamelContextWithLife
assertTrue(context.getStatus().isStarted());
assertFalse(context.getStatus().isStopped());
assertEquals(1, context.getRoutes().size());
- assertEquals(1, strategy.getCounter().get());
+ assertEquals(1, strategy.getContextStartCounter());
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
@@ -62,7 +61,7 @@ public class DefaultCamelContextWithLife
assertTrue(context.getStatus().isStarted());
assertFalse(context.getStatus().isStopped());
assertEquals(1, context.getRoutes().size());
- assertEquals(2, strategy.getCounter().get());
+ assertEquals(2, strategy.getContextStartCounter());
// must obtain a new template
template = context.createProducerTemplate();
@@ -73,6 +72,17 @@ public class DefaultCamelContextWithLife
assertMockEndpointsSatisfied();
}
+ public void testRouteStopped() throws Exception {
+ assertTrue(context.getRouteStatus("foo").isStarted());
+ assertEquals(0, strategy.getRemoveCounter());
+
+ context.stopRoute("foo");
+ assertEquals(0, strategy.getRemoveCounter());
+
+ context.removeRoute("foo");
+ assertEquals(1, strategy.getRemoveCounter());
+ }
+
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
@@ -93,11 +103,12 @@ public class DefaultCamelContextWithLife
private class MyStrategy implements LifecycleStrategy {
- private AtomicInteger counter = new AtomicInteger();
+ private AtomicInteger contextStartCounter = new AtomicInteger();
+ private AtomicInteger removeCounter = new AtomicInteger();
@Override
public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- counter.incrementAndGet();
+ contextStartCounter.incrementAndGet();
}
@Override
@@ -134,6 +145,7 @@ public class DefaultCamelContextWithLife
@Override
public void onRoutesRemove(Collection<Route> routes) {
+ removeCounter.incrementAndGet();
}
@Override
@@ -148,8 +160,12 @@ public class DefaultCamelContextWithLife
public void onThreadPoolAdd(CamelContext camelContext, ThreadPoolExecutor threadPool, String id, String sourceId, String routeId, String threadPoolProfileId) {
}
- public AtomicInteger getCounter() {
- return counter;
+ public int getContextStartCounter() {
+ return contextStartCounter.get();
+ }
+
+ public int getRemoveCounter() {
+ return removeCounter.get();
}
}
}