You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Surjit Sen (JIRA)" <ji...@apache.org> on 2017/02/04 22:52:51 UTC

[jira] [Created] (CAMEL-10789) Indexing with simple expression broken in Apache Camel 2.18

Surjit Sen created CAMEL-10789:
----------------------------------

             Summary: Indexing with simple expression broken in Apache Camel 2.18
                 Key: CAMEL-10789
                 URL: https://issues.apache.org/jira/browse/CAMEL-10789
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.18.2, 2.18.1, 2.18.0
         Environment: Camel 2.18.0/2.18.1/2.18.2 with JDK 1.8.0_112
            Reporter: Surjit Sen
            Priority: Minor
             Fix For: 2.18.3


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}]]



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)