Hi All,

I’m seeing a java.lang.ClassCastException in
PooledProcessorExchangeFactory when
using the Splitter with exchange pooling enabled in Camel 4.17.0.

The same code works in Camel 4.3.0, so I suspect this might be a regression.


Callstack:

Caused by: java.lang.ClassCastException: class
org.apache.camel.support.MonotonicClock cannot be cast to class
org.apache.camel.support.ResetableClock
(org.apache.camel.support.MonotonicClock and
org.apache.camel.support.ResetableClock are in unnamed module of loader
'app')

at
org.apache.camel.impl.engine.PooledProcessorExchangeFactory.createCopy(PooledProcessorExchangeFactory.java:76)

at
org.apache.camel.processor.Splitter.copyAndPrepareSubExchange(Splitter.java:314)

at
org.apache.camel.processor.Splitter$SplitterIterable.<init>(Splitter.java:178)

at
org.apache.camel.processor.Splitter.createProcessorExchangePairsIterable(Splitter.java:152)

at
org.apache.camel.processor.Splitter.createProcessorExchangePairs(Splitter.java:140)

at
org.apache.camel.processor.MulticastProcessor.doProcess(MulticastProcessor.java:336)

at
org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:328)

at org.apache.camel.processor.Splitter.process(Splitter.java:126)


Test Code:

public class SplitterPolledExchangeTest extends CamelTestSupport {


   @Override

   protected RoutesBuilder createRouteBuilder() {

       return new RouteBuilder() {

           @Override

           public void configure() {

               from("direct:processData")

                       .split(body()).streaming().parallelProcessing()

                       .to("mock:result");

           }

       };

   }


  @Override

   protected CamelContext createCamelContext() throws Exception {

       CamelContext camelContext = super.createCamelContext();

       ExtendedCamelContext ecc = camelContext.getCamelContextExtension();


       ecc.setExchangeFactory(new PooledExchangeFactory());

       ecc.setProcessorExchangeFactory(new
PooledProcessorExchangeFactory());

       ecc.getExchangeFactory().setStatisticsEnabled(true);

       ecc.getProcessorExchangeFactory().setStatisticsEnabled(true);


       return camelContext;

   }


   @Test

   public void testSplitter() throws Exception {

       List<Integer> data = new ArrayList<>(Arrays.asList(1, 2, 3));


       getMockEndpoint("mock:result").expectedMessageCount(3);

       template.sendBody("direct:processData", data);


       MockEndpoint.assertIsSatisfied(context);

   }

}

Camel Version: 4.17.0

Java Version: 17


Is this expected behavior, or is this a bug in Camel 4.17.0?
Are there recommended workarounds for using the Splitter with exchange
pooling enabled?


Thanks,

DK

Reply via email to