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

Indexing with simple expression broken in Apache Camel 2.18

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.18.0, 2.18.1, 2.18.2
    • Fix Version/s: 2.18.3
    • Component/s: camel-core
    • Labels:
      None
    • Environment:

      Camel 2.18.0/2.18.1/2.18.2 with JDK 1.8.0_112

      Description

      The following sample code works fine with version 2.17.4 (JDK 1.7), but fails on Camel 2.18.0, 2.18.1 and 2.18.2 (JDK 1.8)

      from("direct:process")
              .process(new Processor() {
                  public void process(Exchange exchange) {
                      List<String> alist = new ArrayList<String>();
                      alist.add("1");
                      alist.add("99");
                      exchange.getIn().setHeader("ITEMS", alist);
                      exchange.getIn().setHeader("TOTAL_LOOPS", alist.size());
                  }
              })
              .loop(simple("${header.TOTAL_LOOPS}", Integer.class))
                .setHeader("item", simple("${header.ITEMS[${property.CamelLoopIndex}]}", String.class))
                .log(LoggingLevel.INFO, LOG_CLASS_NAME, simple("item = ${header.item} and TOTAL_MAPS = ${header.TOTAL_LOOPS}").getText())
              .end()
              .end();
      

      With 2.18.x, the following exception gets thrown:

      2017-02-03 21:13:31 ERROR DefaultErrorHandler:204 - Failed delivery for (MessageId: ID-CATL0W10D4DG4R1-55822-1486174410756-0-1 on ExchangeId: ID-CATL0W10D4DG4R1-55822-1486174410756-0-2). Exhausted after delivery attempt: 1 caught: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: [${property.CamelLoopIndex}] on java.util.ArrayList due to: java.lang.IndexOutOfBoundsException: Key: ${property.CamelLoopIndex} not found in bean: [1, 99] of type: java.util.ArrayList using OGNL path [[${property.CamelLoopIndex}]]
      

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              surjitsen Surjit Sen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: