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 10:54:41 UTC
svn commit: r1206414 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/impl/DefaultCamelContext.java
test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
Author: davsclaus
Date: Sat Nov 26 09:54:40 2011
New Revision: 1206414
URL: http://svn.apache.org/viewvc?rev=1206414&view=rev
Log:
CAMEL-4696: Fixed issue when removing route causing 2 times shutdown. Thanks to Bilgin for patch.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1206414&r1=1206413&r2=1206414&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Sat Nov 26 09:54:40 2011
@@ -816,7 +816,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/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java?rev=1206414&r1=1206413&r2=1206414&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java Sat Nov 26 09:54:40 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();
}
}
}