There is a jsp file called test.jsp: <%@ page contentType="text/html; charset=UTF-8" %> <jsp:directive.page import="java.util.Map"/> <jsp:directive.page import="java.util.HashMap"/> <%!public class CellAttributes{ private String cellValue; public CellAttributes(String cellValue) { this.cellValue = cellValue; } public String getCellValue() { return cellValue; } } %> <%Map<String,CellAttributes> currentRow = new HashMap<String, CellAttributes>(); currentRow.put("a",new CellAttributes("")); currentRow.put("b",new CellAttributes("1")); pageContext.setAttribute("currentRow",currentRow); %> <Html> <BODY> ${currentRow['a'].cellValue+currentRow['b'].cellValue} </BODY> </Html> throws exception: java.lang.NumberFormatException: For input string: "" java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) java.lang.Long.parseLong(Long.java:424) java.lang.Long.<init>(Long.java:671) org.apache.el.lang.ELArithmetic$LongDelegate.coerce(ELArithmetic.java:186) org.apache.el.lang.ELArithmetic.coerce(ELArithmetic.java:357) org.apache.el.lang.ELArithmetic.add(ELArithmetic.java:235) org.apache.el.parser.AstPlus.getValue(AstPlus.java:40) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935) org.apache.jsp.new_jsp._jspService(new_jsp.java:84) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) but I think it should be "1"
Thanks for the test case, it really helps speed up the process of evaluating bugs. + is not a String concatenation operator in EL. However, I think this will achieve the result you want: ${currentRow['a'].cellValue}${currentRow['b'].cellValue}
Even without string concatenation, you receive the NumberFormat exception with the following expression : ${4+currentRow['a'].cellValue} With ${4+currentRow['b'].cellValue}, the result is OK. Why the empty string test is placed after the String instance test inside the method org.apache.el.lang.ELArithmetic.coerce ?
Confirming in trunk, both the original issue and the one in Comment 2. From expression_language-2_2-mrel-spec.pdf: The '+' operator is defined in chapter 1.7.1. There is the following step there: Otherwise coerce both A and B to Long and apply operator Coercion to Long is covered by chapter 1.18.3. If A is null or "", return 0. Throwing a NumberFormatException for the empty string is a bug.
Created attachment 26928 [details] Patch for ELArithmetic
Thanks for the patch. It has been applied (along with a test case) to 7.0.x and will be included in 7.0.13 onwards. The patch has also been proposed for 6.0.x.
Drop the severity.
Fixed in 6.0.x and will be included in 6.0.33 onwards.