Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16767

camel-core - Stoping route failed with NPE when route contains loopDoWhile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.8.0
    • 3.11.1, 3.12.0
    • camel-core
    • None
    • Novice

    Description

      Stopping route failed route is not called at least once.

      @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());
      }
      

      The problem is in LoopProcessor.java which does not contains default value:

          @Override
          public int getPendingExchangesSize() {
              return state.getPendingSize();  // here is missing NPE check
          }
      

      Given exception is 

      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
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            petrfilip Petr Filip
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified