diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java index 5f5df5be1a6..37febf4dfa5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java @@ -218,6 +218,10 @@ public abstract class Operator extends SpelNodeImpl { return left.toString().equals(right.toString()); } + if (left instanceof Boolean && right instanceof Boolean) { + return left.equals(right); + } + if (ObjectUtils.nullSafeEquals(left, right)) { return true; } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java index 8a31cd6f1c0..b8420a98e32 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java @@ -118,10 +118,8 @@ public class SpelExpression implements Expression { public Object getValue() throws EvaluationException { if (this.compiledAst != null) { try { - TypedValue contextRoot = - (this.evaluationContext != null ? this.evaluationContext.getRootObject() : null); - return this.compiledAst.getValue( - (contextRoot != null ? contextRoot.getValue() : null), this.evaluationContext); + EvaluationContext context = getEvaluationContext(); + return this.compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted @@ -148,10 +146,8 @@ public class SpelExpression implements Expression { public T getValue(@Nullable Class expectedResultType) throws EvaluationException { if (this.compiledAst != null) { try { - TypedValue contextRoot = - (this.evaluationContext != null ? this.evaluationContext.getRootObject() : null); - Object result = this.compiledAst.getValue( - (contextRoot != null ? contextRoot.getValue() : null), this.evaluationContext); + EvaluationContext context = getEvaluationContext(); + Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType == null) { return (T) result; } @@ -185,7 +181,7 @@ public class SpelExpression implements Expression { public Object getValue(Object rootObject) throws EvaluationException { if (this.compiledAst != null) { try { - return this.compiledAst.getValue(rootObject, this.evaluationContext); + return this.compiledAst.getValue(rootObject, getEvaluationContext()); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted @@ -213,7 +209,7 @@ public class SpelExpression implements Expression { public T getValue(Object rootObject, @Nullable Class expectedResultType) throws EvaluationException { if (this.compiledAst != null) { try { - Object result = this.compiledAst.getValue(rootObject, null); + Object result = this.compiledAst.getValue(rootObject, getEvaluationContext()); if (expectedResultType == null) { return (T)result; } @@ -250,8 +246,7 @@ public class SpelExpression implements Expression { if (this.compiledAst != null) { try { - TypedValue contextRoot = context.getRootObject(); - return this.compiledAst.getValue(contextRoot.getValue(), context); + return this.compiledAst.getValue(context.getRootObject().getValue(), context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted @@ -280,8 +275,7 @@ public class SpelExpression implements Expression { if (this.compiledAst != null) { try { - TypedValue contextRoot = context.getRootObject(); - Object result = this.compiledAst.getValue(contextRoot.getValue(), context); + Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context); if (expectedResultType != null) { return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType); } @@ -315,7 +309,7 @@ public class SpelExpression implements Expression { if (this.compiledAst != null) { try { - return this.compiledAst.getValue(rootObject,context); + return this.compiledAst.getValue(rootObject, context); } catch (Throwable ex) { // If running in mixed mode, revert to interpreted