From ddb852cdf7da29827fcab0b25a2b2ed6ee443cf9 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Sun, 12 Jun 2016 11:39:46 +0200 Subject: [PATCH] CAMEL-10048: Fixed memory leak in routing slip. Thanks to Arseniy Tashoyan for the patch. --- .../java/org/apache/camel/processor/RoutingSlip.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 641834c821a4c..d2d46aff70fc0 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 @@ -80,9 +80,9 @@ public class RoutingSlip extends ServiceSupport implements AsyncProcessor, Trace *

* This is similar to how multicast processor does. */ - static final class PreparedErrorHandler extends KeyValueHolder { + static final class PreparedErrorHandler extends KeyValueHolder { - PreparedErrorHandler(RouteContext key, Processor value) { + PreparedErrorHandler(String key, Processor value) { super(key, value); } @@ -324,7 +324,7 @@ protected Exchange prepareExchangeForRoutingSlip(Exchange current, Endpoint endp 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); @@ -337,7 +337,7 @@ protected AsyncProcessor createErrorHandler(RouteContext routeContext, Exchange // 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); @@ -379,7 +379,7 @@ public boolean doInAsyncProducer(Producer producer, AsyncProcessor asyncProducer // 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());