Skip to content

Commit 138fa8a

Browse files
jhoellerunknown
authored andcommitted
OpDivide does not return a TypedValue for its operate result (consistent with OpMultiply)
Issue: SPR-9869
1 parent ff7dcec commit 138fa8a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 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.
@@ -25,6 +25,7 @@
2525
* Implements division operator.
2626
*
2727
* @author Andy Clement
28+
* @author Juergen Hoeller
2829
* @since 3.0
2930
*/
3031
public class OpDivide extends Operator {
@@ -42,14 +43,16 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep
4243
Number op2 = (Number) operandTwo;
4344
if (op1 instanceof Double || op2 instanceof Double) {
4445
return new TypedValue(op1.doubleValue() / op2.doubleValue());
45-
} else if (op1 instanceof Long || op2 instanceof Long) {
46+
}
47+
else if (op1 instanceof Long || op2 instanceof Long) {
4648
return new TypedValue(op1.longValue() / op2.longValue());
47-
} else { // TODO what about non-int result of the division?
49+
}
50+
else {
51+
// TODO what about non-int result of the division?
4852
return new TypedValue(op1.intValue() / op2.intValue());
4953
}
5054
}
51-
Object result = state.operate(Operation.DIVIDE, operandOne, operandTwo);
52-
return new TypedValue(result);
55+
return state.operate(Operation.DIVIDE, operandOne, operandTwo);
5356
}
5457

5558
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ public OpMultiply(int pos, SpelNodeImpl... operands) {
4848
* Implements the {@code multiply} operator directly here for certain types
4949
* of supported operands and otherwise delegates to any registered overloader
5050
* for types not supported here.
51-
*
5251
* <p>Supported operand types:
5352
* <ul>
5453
* <li>doubles
5554
* <li>longs
5655
* <li>integers
57-
* <li>string and int ('abc' * 2 == 'abcabc')
56+
* <li>String and int ('abc' * 2 == 'abcabc')
5857
* </ul>
5958
*/
6059
@Override

0 commit comments

Comments
 (0)