Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-142

Map expression issue with empty key

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 3.0
    • Labels:
      None

      Description

      Map expressions fail if key is an empty string: map['']

      Attachement contains patch with a fix and test case.

      java.lang.StringIndexOutOfBoundsException: String index out of range: 3
      at java.lang.AbstractStringBuilder.charAt(Unknown Source)
      at java.lang.StringBuilder.charAt(Unknown Source)
      at org.apache.commons.jexl2.internal.PropertyGetExecutor.discoverGet(PropertyGetExecutor.java:103)
      at org.apache.commons.jexl2.internal.PropertyGetExecutor.discover(PropertyGetExecutor.java:82)
      at org.apache.commons.jexl2.internal.PropertyGetExecutor.<init>(PropertyGetExecutor.java:38)
      at org.apache.commons.jexl2.internal.Introspector.getGetExecutor(Introspector.java:230)
      at org.apache.commons.jexl2.introspection.UberspectImpl.getPropertyGet(UberspectImpl.java:136)
      at org.apache.commons.jexl2.Interpreter.getAttribute(Interpreter.java:1537)
      at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:482)
      at org.apache.commons.jexl2.parser.ASTArrayAccess.jjtAccept(ASTArrayAccess.java:18)
      at org.apache.commons.jexl2.Interpreter.visit(Interpreter.java:1317)
      at org.apache.commons.jexl2.parser.ASTReference.jjtAccept(ASTReference.java:18)
      at org.apache.commons.jexl2.Interpreter.interpret(Interpreter.java:232)
      at org.apache.commons.jexl2.ExpressionImpl.evaluate(ExpressionImpl.java:65)
      at org.apache.commons.jexl2.MapLiteralTest.testLiteralWithNumbers(MapLiteralTest.java:99)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at junit.framework.TestCase.runTest(TestCase.java:168)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:110)
      at junit.framework.TestResult.runProtected(TestResult.java:128)
      at junit.framework.TestResult.run(TestResult.java:113)
      at junit.framework.TestCase.run(TestCase.java:124)
      at junit.framework.TestSuite.runTest(TestSuite.java:243)
      at junit.framework.TestSuite.run(TestSuite.java:238)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

        Attachments

        1. JEXL-142.patch
          1 kB
          Juozas Baliuks

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jbaliuka Juozas Baliuks
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: