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

simple language nullsafe expression fails on empty array

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.17.3, 2.18.0
    • Fix Version/s: 2.18.1, 2.19.0
    • Component/s: camel-core
    • Labels:
      None
    • Patch Info:
      Patch Available
    • Estimated Complexity:
      Unknown
    • Flags:
      Patch

      Description

      limitation w/ simple language on the 1st index of an empty array with a nullsafe expression

      sample expression: ${in.body?.list[0].toString}

      org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: ?.get('list')[0].toString on java.util.HashMap due to: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:120)
      at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:138)
      at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:126)
      at org.apache.camel.model.language.ExpressionDefinition.evaluate(ExpressionDefinition.java:118)
      at org.apache.camel.builder.ExpressionBuilder$40.evaluate(ExpressionBuilder.java:993)
      at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
      at org.apache.camel.TestSupport.assertExpression(TestSupport.java:255)
      at org.apache.camel.ContextTestSupport.assertExpression(ContextTestSupport.java:314)
      at org.apache.camel.LanguageTestSupport.assertExpression(LanguageTestSupport.java:62)
      at org.apache.camel.LanguageTestSupport.assertExpression(LanguageTestSupport.java:69)
      at org.apache.camel.language.simple.SimpleTest.testOGNLBodyEmptyList(SimpleTest.java:267)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at junit.framework.TestCase.runTest(TestCase.java:176)
      at junit.framework.TestCase.runBare(TestCase.java:141)
      at org.apache.camel.TestSupport.runBare(TestSupport.java:58)
      at junit.framework.TestResult$1.protect(TestResult.java:122)
      at junit.framework.TestResult.runProtected(TestResult.java:142)
      at junit.framework.TestResult.run(TestResult.java:125)
      at junit.framework.TestCase.run(TestCase.java:129)
      at junit.framework.TestSuite.runTest(TestSuite.java:252)
      at junit.framework.TestSuite.run(TestSuite.java:247)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:653)
      at java.util.ArrayList.get(ArrayList.java:429)
      at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.lookupResult(BeanExpression.java:385)
      at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:334)
      at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:114)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                dmitriyC300 Dmitriy Frolov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: