Author: markt Date: Thu Oct 23 13:23:33 2014 New Revision: 1633806 URL: http://svn.apache.org/r1633806 Log: When coercing an object to a given type, only attempt coercion to an array if both the object type and the target type are an array type. Based on a patch by violetagg.
Modified: tomcat/trunk/java/org/apache/el/lang/ELSupport.java tomcat/trunk/test/javax/el/TestUtil.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/el/lang/ELSupport.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELSupport.java?rev=1633806&r1=1633805&r2=1633806&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/el/lang/ELSupport.java (original) +++ tomcat/trunk/java/org/apache/el/lang/ELSupport.java Thu Oct 23 13:23:33 2014 @@ -482,7 +482,7 @@ public class ELSupport { } // Handle arrays - if (type.isArray()) { + if (type.isArray() && obj.getClass().isArray()) { return coerceToArray(obj, type); } Modified: tomcat/trunk/test/javax/el/TestUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestUtil.java?rev=1633806&r1=1633805&r2=1633806&view=diff ============================================================================== --- tomcat/trunk/test/javax/el/TestUtil.java (original) +++ tomcat/trunk/test/javax/el/TestUtil.java Thu Oct 23 13:23:33 2014 @@ -41,9 +41,16 @@ public class TestUtil { @Test - public void testBug56425() { + public void testBug56425a() { ELProcessor processor = new ELProcessor(); processor.defineBean("string", "a-b-c-d"); Assert.assertEquals("a_b_c_d", processor.eval("string.replace(\"-\",\"_\")")); } + + @Test + public void testBug56425b() { + ELProcessor processor = new ELProcessor(); + processor.defineBean("string", "Not used. Any value is fine here"); + Assert.assertEquals("5", processor.eval("string.valueOf(5)")); + } } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1633806&r1=1633805&r2=1633806&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Oct 23 13:23:33 2014 @@ -205,6 +205,11 @@ <bug>57132</bug>: Fix import conflicts reporting in Expression Language. (kkolinko) </fix> + <fix> + When coercing an object to a given type, only attempt coercion to an + array if both the object type and the target type are an array type. + (violetagg/markt) + </fix> </changelog> </subsection> <subsection name="Cluster"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org