SpEL expression 1: #T_34900>=0.0

SpEL expression 2: #T_34900<=0.0

When #T_34900 value is NULL:

  • Expression 1 evaluates to FALSE
  • Expression 2 evaluates to TRUE

The reason is that StandardTypeComparator returns -1. Expression 1 is equal to -1 >= 0, and expression 2 is equal to -1 <= 0.

Is it a feature or a bug?

In my opinion, the compare result is stationary when input is NULL.

org.springframework.expression.spel.ast.OpLE line 65: return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) <= 0);

org.springframework.expression.spel.ast.OpGE line 65: return BooleanTypedValue.forValue(state.getTypeComparator().compare(left, right) >= 0);

Comment From: sbrannen

Hi @ChenBerlin,

Congratulations on submitting your first issue for the Spring Framework! 👍

Is it a feature or a bug?

That is by design and is documented in the Relational Operators section of the reference guide.

Greater-than and less-than comparisons against null follow a simple rule: null is treated as nothing (that is NOT as zero). As a consequence, any other value is always greater than null (X > null is always true) and no other value is ever less than nothing (X < null is always false).

In light of the above, I am closing this issue.

Regards,

Sam