I am trying to upgrade spring version from version 3.0.5 to 3.2.11.
I am having problems with SpEL when an expression compares a null value as follows:
new SpelExpressionParser().parseExpression("null < 7").getValue();
The result of the above code results in
- false when using version 3.0.5
- true when using version 3.2.11, which is incorrect due to my opinion
The reason for this different behavior is that in the StandartTypeComparator class, which is used inside SpEL, there is a different implementation of the comparison method:
version 3.0.5
public int compare(Object left, Object right) throws SpelEvaluationException {
if (left == null) {
return right == null ? 0 : 1;
} else if (right == null) {
return -1;
}
version 3.2.11
public int compare(Object left, Object right) throws SpelEvaluationException {
if (left == null) {
return right == null ? 0 : -1;
} else if (right == null) {
return 1;
}
When I follow the code above, I see that the launch
new SpelExpressionParser().parseExpression("7 < null").getValue();
will result in:
- true when using version 3.0.5, which is incorrect, due to my opinion
- false when using version 3.2.11
.
, - , , , , . , ?
?
- , , <, > , ==, < =, >= operator?