Skip to content

Commit e410129

Browse files
aclementjhoeller
authored andcommitted
Ensure cast correctly included for OpPlus compilation
When the plus operator is used between strings in a SpEL expression and that expression is compiled, it is important to include a cast if computation of any of the operands isn't obviously leaving strings on the stack. Likewise if the stack contents are known to be strings, a cast should not be included. Issue: SPR-12426 (cherry picked from commit 58756b0)
1 parent 5549436 commit e410129

File tree

2 files changed

+623
-583
lines changed

2 files changed

+623
-583
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpPlus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -206,7 +206,7 @@ private void walk(MethodVisitor mv, CodeFlow cf, SpelNodeImpl operand) {
206206
else {
207207
cf.enterCompilationScope();
208208
operand.generateCode(mv,cf);
209-
if (cf.lastDescriptor() != "Ljava/lang/String") {
209+
if (!"Ljava/lang/String".equals(cf.lastDescriptor())) {
210210
mv.visitTypeInsn(CHECKCAST, "java/lang/String");
211211
}
212212
cf.exitCompilationScope();

0 commit comments

Comments
 (0)