Mantis - Resin
Viewing Issue Advanced Details
919 major always 02-06-06 17:15 04-07-06 10:02
closed 3.0.17  
none 3.0.19  
0000919: JSTL EL: numeric binary expression type promotion order is out-of-spec
The JSP 2.0 specification (JSP. specifies the sequence in which type promotion checks on binary operator arguments should be performed. In particular, the specification calls for the treatment of String-valued operands that include "tell-tale" float/double characters to be identical to that of actual Float or Double operands. That is, the presence of a String-valued operand that "looks like" a Float or a Double is supposed to cause the binary operator to be evaluated against the pair of operands after coercing them both to Double.

The Resin "BinaryExpr" class, however, has tests that prefer operands that are "Number" instances to Strings that look like Doubles. The result is that an expression like

  ${0 +}

will fail when the String operand looks like "1.0". The failure occurs because Resin notices that the first operand is a Long (i.e., a Number) before it checks to see whether the second operand is a String that looks like a Double. In my opinion that behavior is clearly counter to the spec.

For reasons I can't explain, this did not seem to be a problem in the 3.0.14 version, though the code seems similar in intent.
Incidentally, in the 3.0.17 source there's a bug that was also in the 3.0.14 source. The test to see whether the "B" operand is a Float or a Double instead checks to see whether it's a Double twice:

    if (bObj instanceof Double || bObj instanceof Double) {

(line 112 in the 3.0.17 source).

04-07-06 10:02