Camel error using InterceptFrom and Intercept strategy at the same time

Solution Verified - Updated -

Issue

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: Test]
at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1379)
at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:283)
at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:381)
at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:346)
at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:242)
at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:346)
Caused by: java.lang.StackOverflowError
at java.lang.ThreadLocal$ThreadLocalMap.nextIndex(ThreadLocal.java:313)
at java.lang.ThreadLocal$ThreadLocalMap.expungeStaleEntry(ThreadLocal.java:563)
at java.lang.ThreadLocal$ThreadLocalMap.remove(ThreadLocal.java:461)
at java.lang.ThreadLocal$ThreadLocalMap.access$200(ThreadLocal.java:261)
at java.lang.ThreadLocal.remove(ThreadLocal.java:202)
  • Below is the code that we tested with,
 protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                // add a dummy strategy
                // removing this line the test works
                context.addInterceptStrategy(new DummyStrategy());
                // intercet from
                interceptFrom("direct:start").log("Intercepted");

                from("direct:start").to("mock:result");
            }
        };
    }
    class DummyStrategy implements InterceptStrategy {

        @Override
        public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition<?> definition, Processor target, Processor nextTarget)
                throws Exception {

            return target;
        }
    }
  • The stack shows me StackOverFlowError on the org.apache.camel.processor.InterceptorToAsyncProcessorBridge.process() for the affected camel versions.

Environment

  • Red Hat JBoss Fuse
    • 6.1.0
  • Apache Camel

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content