Natalia Shashok created FREEMARKER-227:
------------------------------------------
Summary: ClassicCompatible setting doesn't work with sequence
built-ins as expected
Key: FREEMARKER-227
URL: https://issues.apache.org/jira/browse/FREEMARKER-227
Project: Apache Freemarker
Issue Type: Bug
Affects Versions: 2.3.30
Reporter: Natalia Shashok
When turning classic compatible mode to true, usage of seq_contains,
seq_index_of, seq_last_index_of built-ins becomes unstable.
Consider the following template:
<#setting classic_compatible=true>
<#if eight?seq_contains(1)> </#if>
If the next values are passed to generate a document:
eight=[ "2", "1", "3"]
then generation fails with the following error:
{code:java}
Expression has thrown an unchecked exception; see the cause exception.The
blamed expression:==> eight?seq_contains(1) [in nameless template at line 2,
column 6]
----FTL stack trace ("~" means nesting-related): - Failed at: #if
eight?seq_contains(1)?? [in nameless template at line 2, column 1]----
Caused by:java.lang.NullPointerException: null{code}
After further investigation it was found out that
1) seq_ built-ins react badly on integers, whether the integer is actually
contained within the sequence or not;
2) seq_ built-ins work correctly on strings if the strings passed to built-ins
is contained within the sequence, but will fail with the same
NullPointerException if the string isn't contained within the sequence.
Is there any way to mitigate these errors upon using classic_compatible mode?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)