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

weaveAddLast throwing UnsupportedOperation when route have a ChoiceDefinition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.14.2, 2.15.0, 2.15.1, 2.15.2
    • 2.15.3, 2.16.0, 2.14.4
    • camel-core
    • None
    • JDK 7.0 64bits

    • Unknown
    • Regression

    Description

      I'm currently upgrading from Camel 2.14.1 to 2.15.2, after the upgrade some of my test are failing.

      My route is:

      from("file:input?idempotent=true&moveFailed=.error").routeId("MyRoute")
              .choice()
                   .when(body().isEqualTo("body1"))
                       .log("body1")
                   .otherwise()
                      .log("notBody1")
             .end()
       

      My test contains :

      camelContext.getRouteDefinition("MyRoute").adviceWith(camelContext, new AdviceWithRouteBuilder() {
                  @Override
                  public void configure() {
                      weaveAddLast().to(mockOutput);
                  }
              });
      

      The weaveAddLast is failing with the following stackTrace:

      java.lang.UnsupportedOperationException 
              at java.util.AbstractList.add(AbstractList.java:148) 
              at org.apache.camel.builder.AdviceWithTasks$4.task(AdviceWithTasks.java:298) 
              at org.apache.camel.model.RouteDefinition.adviceWith(RouteDefinition.java:270) 
      

      After some debug I found that when my route and with a Choice I cannot weaveAddLast the route.
      When the AdviceWithTasks task method try to add the outputs (here) the implementation of the list return by the ChoiceDefinition class does not implements the method add(int,Object) then we have the UnsupportedOperation

      The difference between 2.14.1 and 2.15.2 is that in the AdviceWithTasks the outputs list where the weaveAddLast try to find the last Processor to add the outputs is not a list returned by ChoiceDefinition but it's a list with the Logs processor.

      This difference is there because now in 2.15.2 the method that is going through the route to retrieve the outputs nodes have a maximum depth which is computed here

      When my route have finish with a ChoiceDefinition the maximum depth computed is only 1 then I cannot have my logs in outputs an the weaveAddLast have in his list only the ChoiceDefinition.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            gterral Terral Guillaume
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: