Upgraded from Spring Framework 5.3.15 to 5.3.16 (via Boot) and this expression
T(Character).isUpperCase(c) ? 'uppercase' : 'lowercase'
now throws the exception
org.springframework.expression.spel.SpelEvaluationException: EL1005E: Type cannot be found 'Character'
at org.springframework.expression.spel.support.StandardTypeLocator.findType(StandardTypeLocator.java:117)
at org.thymeleaf.spring5.expression.ThymeleafEvaluationContext$ThymeleafEvaluationContextACLTypeLocator.findType(ThymeleafEvaluationContext.java:193)
at org.springframework.expression.spel.ExpressionState.findType(ExpressionState.java:155)
at org.springframework.expression.spel.ast.TypeReference.getValueInternal(TypeReference.java:69)
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:55)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:91)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:188)
at org.springframework.expression.spel.ast.Ternary.getValueInternal(Ternary.java:53)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:112)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:337)
at org.thymeleaf.spring5.expression.SPELVariableExpressionEvaluator.evaluate(SPELVariableExpressionEvaluator.java:265)
... 164 more
Changing it to java.lang.Character works again.
Possibly it's a Thymeleaf (3.0.14 -> 3.0.15) issue instead?
Comment From: sbrannen
Possibly it's a Thymeleaf (3.0.14 -> 3.0.15) issue instead?
Yes, I assume it's an issue with Thymeleaf.
I am not able to reproduce that SpelEvaluationException against 5.3.x (i.e., 5.3.17 snapshots) or main.
For example, adding the following to one of the test methods in SpelDocumentationTests works without any issue.
evaluate("(T(Math).random() * 100.0) > 0", true, Boolean.class);
evaluate("T(Character).isUpperCase('Test'.charAt(0)) ? 'uppercase' : 'lowercase'", "uppercase", String.class);
evaluate("T(Character).isUpperCase('Test'.charAt(1)) ? 'uppercase' : 'lowercase'", "lowercase", String.class);
In light of that I am closing this issue.
Please raise an issue with the Thymeleaf team.
Comment From: OrangeDog
I missed it because I looked in thymeleaf-spring instead of thymeleaf: https://github.com/thymeleaf/thymeleaf/issues/878