CAMEL-10048: Fixed memory leak in routing slip. Thanks to Arseniy Tashoyan for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f17b51d1 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f17b51d1 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f17b51d1 Branch: refs/heads/camel-2.16.x Commit: f17b51d18b990e0ef6de56c7d59392b7e3d8f280 Parents: c7ef72a Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Jun 12 11:39:46 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Jun 12 11:42:03 2016 +0200 ---------------------------------------------------------------------- .../java/org/apache/camel/processor/RoutingSlip.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f17b51d1/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java b/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java index c684593..d2d46af 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java +++ b/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java @@ -41,7 +41,6 @@ import org.apache.camel.impl.ProducerCache; import org.apache.camel.spi.EndpointUtilizationStatistics; import org.apache.camel.spi.IdAware; import org.apache.camel.spi.RouteContext; -import org.apache.camel.spi.UnitOfWork; import org.apache.camel.support.ServiceSupport; import org.apache.camel.util.AsyncProcessorHelper; import org.apache.camel.util.ExchangeHelper; @@ -81,9 +80,9 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor, Trace * <p/> * This is similar to how multicast processor does. */ - static final class PreparedErrorHandler extends KeyValueHolder<RouteContext, Processor> { + static final class PreparedErrorHandler extends KeyValueHolder<String, Processor> { - public PreparedErrorHandler(RouteContext key, Processor value) { + PreparedErrorHandler(String key, Processor value) { super(key, value); } @@ -325,7 +324,7 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor, Trace return copy; } - protected AsyncProcessor createErrorHandler(RouteContext routeContext, Exchange exchange, AsyncProcessor processor) { + protected AsyncProcessor createErrorHandler(RouteContext routeContext, Exchange exchange, AsyncProcessor processor, Endpoint endpoint) { AsyncProcessor answer = processor; boolean tryBlock = exchange.getProperty(Exchange.TRY_ROUTE_BLOCK, false, boolean.class); @@ -338,7 +337,7 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor, Trace // for the entire routingslip/dynamic-router block again which will start from scratch again // create key for cache - final PreparedErrorHandler key = new PreparedErrorHandler(routeContext, processor); + final PreparedErrorHandler key = new PreparedErrorHandler(endpoint.getEndpointUri(), processor); // lookup cached first to reuse and preserve memory answer = errorHandlers.get(key); @@ -380,7 +379,7 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor, Trace // rework error handling to support fine grained error handling RouteContext routeContext = exchange.getUnitOfWork() != null ? exchange.getUnitOfWork().getRouteContext() : null; - asyncProducer = createErrorHandler(routeContext, exchange, asyncProducer); + asyncProducer = createErrorHandler(routeContext, exchange, asyncProducer, endpoint); // set property which endpoint we send to exchange.setProperty(Exchange.TO_ENDPOINT, endpoint.getEndpointUri());