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

Simple Language - Length of array properties is not correctly evaluated

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.13.1
    • Fix Version/s: 2.12.4, 2.13.2, 2.14.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      If the exchange body is an array, then body.length returns correctly the length of the array. However, if the array is a property of an object, then not the correct value is returned:

      MyClass.java
      public class MyClass {
          public Object[] getMyArray() {
              return new Object[]{"Hallo", "World", "!"};
          }
      }
      

      Accessing the property myArray with Simple:

      <setHeader headerName="mySimpleHeader">
          <simple>body.myArray.length</simple>
      </setHeader>
      <log message="mySimpleHeader = ${header.mySimpleHeader}" />
      

      Java:

      final ProducerTemplate template = main.getCamelTemplate();
      template.sendBody("direct:start", new MyClass());
      

      Log:

      [main] route1 INFO  mySimpleHeader = 1
      

      The return value should be 3 instead of 1.

        Attachments

          Activity

            People

            • Assignee:
              njiang Willem Jiang
              Reporter:
              Peter Keller Peter Keller
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: