You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Petr Filip (Jira)" <ji...@apache.org> on 2021/06/29 10:06:00 UTC

[jira] [Created] (CAMEL-16767) Stoping route failed when route contains loopDoWhile

Petr Filip created CAMEL-16767:
----------------------------------

             Summary: Stoping route failed when route contains loopDoWhile
                 Key: CAMEL-16767
                 URL: https://issues.apache.org/jira/browse/CAMEL-16767
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 3.8.0
            Reporter: Petr Filip
             Fix For: 3.x


Stopping route failed route is not called at least once.
{code:java}
@Test
public void addCamelRouteAndStopAndRemoveFailedTest() throws Exception {
  camelContext.addRoutes(new RouteBuilder() {
    public void configure() {
      from("direct:unitTest").routeId("routeId")
        .loopDoWhile(body().isNotNull())
        .log("im in cycle")
        .end();
    }
  });

  Assert.assertEquals(1, camelContext.getRoutes().size());
  camelContext.getRouteController().suspendRoute("routeId");
  camelContext.removeRoute("routeId");
  Assert.assertEquals(0, camelContext.getRoutes().size());
}
{code}
The problem is in _LoopProcessor.java_ which does not contains default value:
{code:java}
    @Override
    public int getPendingExchangesSize() {
        return state.getPendingSize();  // here is missing NPE check
    }
{code}
Given exception is 
{code:java}
Caused by: java.lang.NullPointerExceptionCaused by: java.lang.NullPointerException at org.apache.camel.processor.LoopProcessor.getPendingExchangesSize(LoopProcessor.java:94) at org.apache.camel.impl.engine.DefaultShutdownStrategy.getPendingInflightExchanges(DefaultShutdownStrategy.java:776) at org.apache.camel.impl.engine.DefaultShutdownStrategy$ShutdownTask.run(DefaultShutdownStrategy.java:669) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ... 1 more
{code}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)