Skip to content

Commit

Permalink
CAMEL-10048: Fixed memory leak in routing slip. Thanks to Arseniy Tas…
Browse files Browse the repository at this point in the history
…hoyan for the patch.
  • Loading branch information
davsclaus committed Jun 12, 2016
1 parent e389069 commit ddb852c
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -80,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> {

PreparedErrorHandler(RouteContext key, Processor value) {
PreparedErrorHandler(String key, Processor value) {
super(key, value);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit ddb852c

Please sign in to comment.