Skip to content

Inconsistent results when using SpEL's OpLE and OpGE to handle null values #33981

@ChenBerlin

Description

@ChenBerlin

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);

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions