Expressions no longer support accessing element in ArrayNode with get

Dear Flowable experts,

During an Flowable upgrade from 6.6.0 to 6.8.1 we have observed slightly different behavior at the BeanELResolver. In the older release, it was possible to use the BeanELResolver to invoke ArrayNode::get and pass a Long as parameter, which is no longer possible (even with the current main). This is problematic for us as JUEL expressions like ${array.get(0)} will no longer work because the “0” is treated as a Long.
Is the new behavior intended?

Here is a test that demonstrates the problem:

  @Test
  public void testWithExpression() {
    ObjectMapper om = new ObjectMapper();
    ArrayNode base = om.createArrayNode();
    base.add("firstValue");
    base.add("secondValue");
    base.add("thirdValue");

    DefaultExpressionManager em = new DefaultExpressionManager(null);
    Expression expression = em.createExpression("${array.get(0)}");

    VariableContainerWrapper executionEntityMock = mock(VariableContainerWrapper.class);

    when(executionEntityMock.hasVariable("array")).thenReturn(true);
    when(executionEntityMock.getVariable("array")).thenReturn(base);

    Object result = expression.getValue(executionEntityMock); // MethodNotFoundException: Unable to find unambiguous method: class com.fasterxml.jackson.databind.node.ArrayNode.get(java.lang.Long)

    assertEquals(((TextNode)result).asText(), "firstValue");
  }

The expression can be modified slightly to have the expected outcome (${array.get((0).intValue())} instead of ${array.get(0)}). However, we must ensure backwards compatibility on our side. Therefore, we will have to support expressions like the one mentioned above.

Proposal from our side would be to modify the Util class slightly (1 line of code), which is then used by the BeanELResolver. I have created a pull request with the necessary code change and a small unit test for the BeanELResolver. In case you think some modifications are required to the PR, please feel free to just comment there - I’ll be happy to address the issues. If the current behavior is intended and such expressions should not be used, please let me know, then we will have to find a solution on our side.

Thanks in advance!

Best regards,
Robert

Hey @rssap,

Thanks for the PR and the analysis.

The changed line can be a bit dangerous as JUEL can coerce everything into a String.

Perhaps we can make a more specific solution for ArrayNode in the JsonNodeELResolver. In any case, I would also advise using array[0] instead of array.get(0).intValue() as array[0] will automatically convert the element value into a value literal (if it is not another array or another object).

Cheers,
Filip