KB Article #180013
OS Based Behavior of the Evaluate Selector Filter when using "indexOf()" Function
Problem
With API Gateway on Windows, the following sample evaluation expression would work without issue:
${test.value.indexOf("true") == 0 || test.value.indexOf("false") == 0}" , where test.value is the attribute that has a string value set.
On a Linux installation, the same expression fails to evaluate with the following error:
Could not evaluate boolean expression ${test.value.indexOf("true") == 0 || test.value.indexOf("false") == 0}
Resolution
API Gateway uses JUEL, a third party library, to evaluate expressions.
JUEL sifts through all String methods until it hits an indexOf() method with one parameter and returns that method for evaluation. We hit .indexOf(int) instead of .indexOf(String) and this is what is causing the filter to fail in all other environments except Windows. Juel hits .indexOf(String) first in 7.5.1 SP1 Windows which is what is allowing the filter to pass there.
If a method has the same name and same number of parameters but different parameter types it is possible that the intended method we want will not get called which is the case here. This is a JUEL issue.
After doing a bit of testing, R&D found that the following expressions will return true and carries the same logic as the previous expression, "${test.value.equals("true") || test.value.equals("false")}."
This will always work as Java String class only has one .equals method.
Therefore, it is recommended to use an alternative for the indexOf() function to avoid and future issues when upgrading from API Gateway 7.5.1 on Windows to API Gateway 7.6.2 (not available on Windows).