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

Error in AST/Graph translation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 2.14.0
    • 2.14.1, 2.15.0
    • camel-core
    • None
    • Unknown

    Description

      See https://github.com/hawtio/hawtio/issues/1202

      There could be a problem in camel-core with the graph model generation, in presence of multiple end() calls.

              from("direct:whatever")
                      .split(body()).parallelProcessing().streaming()
                          .setHeader("", simple(""))
                          .process(new Processor() {
                              @Override
                              public void process(Exchange exchange) throws Exception {
                                  
                              }
                          })
                          .choice()
                              .when(simple("something"))
                                  .to("direct:a")
                              .when(simple("something2"))
                                  .to("direct:b")
                              .when(simple("something3"))
                                  .to("direct:c")
                              .otherwise()
                                  .log("whatever")
                          .end()
                      .end()
                      .log("very last");
      

      Produces the equivalent of this xml dump:

      <route xmlns="http://camel.apache.org/schema/spring" id="route2">
              <from uri="direct:whatever1"/>
              <split parallelProcessing="true" streaming="true">
                  <expressionDefinition>body</expressionDefinition>
                  <setHeader headerName="">
                      <simple/>
                  </setHeader>
                  <process/>
                  <choice>
                      <when>
                          <simple>something</simple>
                          <to uri="direct:a"/>
                      </when>
                      <when>
                          <simple>something2</simple>
                          <to uri="direct:b"/>
                      </when>
                      <when>
                          <simple>something3</simple>
                          <to uri="direct:c"/>
                      </when>
                      <otherwise>
                          <log message="whatever"/>
                      </otherwise>
                  </choice>
              </split>
              <log message="very last"/>
          </route>
      

      while using endChoice() in place of the inner end()

      it produces:

      <route xmlns="http://camel.apache.org/schema/spring" id="route3">
              <from uri="direct:whatever2"/>
              <split parallelProcessing="true" streaming="true">
                  <expressionDefinition>body</expressionDefinition>
                  <setHeader headerName="">
                      <simple/>
                  </setHeader>
                  <process/>
                  <choice>
                      <when>
                          <simple>something</simple>
                          <to uri="direct:a"/>
                      </when>
                      <when>
                          <simple>something2</simple>
                          <to uri="direct:b"/>
                      </when>
                      <when>
                          <simple>something3</simple>
                          <to uri="direct:c"/>
                      </when>
                      <otherwise>
                          <log message="whatever"/>
                      </otherwise>
                  </choice>
                  <log message="very last"/>
              </split>
          </route>
      

      Where the difference is in the location of the line <log message="very last"/>

      Is this behavior correct? or should this work already without the need of endChoice() statement?

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            paolo.antinori Paolo Antinori
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: