feel-scala
feel-scala copied to clipboard
The evaluation of `substring()` fails if the length is greater than the given string
Describe the bug
If I invoke the substring() function with a length that is greater than the given string then the evaluation fails and reports a Java StringIndexOutOfBoundsException.
To Reproduce Steps to reproduce the behavior:
- Evaluate the expression
substring("abc", 1, 4) - Verify that the evaluation fails with the message
failed to evaluate expression 'substring("abc", 1, 4)' :
java.lang.StringIndexOutOfBoundsException: begin 0, end 4, length 3
Expected behavior
The function invocation should return the whole string if the length is greater than the string.
substring("abc", 1, 4) // --> "abc"
However, according to the DMN 1.5 specification, the function invocation should return null.
However, returning null is not the most (business) user-friendly behavior. It could lead to complicated expressions, for example:
if string length(message) < 10 then message else substring(message, 1, 10)
Environment
- FEEL engine version:
1.17.4 - Affects:
- Camunda Automation Platform 7: [7.x]
- Zeebe broker:
8.4.0