Author: markt Date: Wed Jun 18 18:52:58 2014 New Revision: 1603576 URL: http://svn.apache.org/r1603576 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56638 When using ELProcessor.defineFunction(String,String,String,String) and no function name is specified, use the method name as the function name as required by the specification.
Modified: tomcat/trunk/java/javax/el/ELProcessor.java tomcat/trunk/test/javax/el/TestELProcessor.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/javax/el/ELProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ELProcessor.java?rev=1603576&r1=1603575&r2=1603576&view=diff ============================================================================== --- tomcat/trunk/java/javax/el/ELProcessor.java (original) +++ tomcat/trunk/java/javax/el/ELProcessor.java Wed Jun 18 18:52:58 2014 @@ -106,6 +106,10 @@ public class ELProcessor { MethodSignature sig = new MethodSignature(context, methodName, className); + if (function.length() == 0) { + function = sig.getName(); + } + Method methods[] = clazz.getMethods(); for (Method method : methods) { if (!Modifier.isStatic(method.getModifiers())) { Modified: tomcat/trunk/test/javax/el/TestELProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/javax/el/TestELProcessor.java?rev=1603576&r1=1603575&r2=1603576&view=diff ============================================================================== --- tomcat/trunk/test/javax/el/TestELProcessor.java (original) +++ tomcat/trunk/test/javax/el/TestELProcessor.java Wed Jun 18 18:52:58 2014 @@ -109,4 +109,24 @@ public class TestELProcessor { elp.eval("fn:test(null)"); Assert.assertEquals("C", TesterFunctions.getCallList()); } + + + @Test + public void testDefineFunctionName06() throws Exception { + TesterFunctions.resetCallList(); + ELProcessor elp = new ELProcessor(); + elp.defineFunction("", "", "javax.el.TesterFunctions", "void doIt(int)"); + elp.eval("doIt(5)"); + Assert.assertEquals("B", TesterFunctions.getCallList()); + } + + + @Test + public void testDefineFunctionName07() throws Exception { + TesterFunctions.resetCallList(); + ELProcessor elp = new ELProcessor(); + elp.defineFunction("fn", "", "javax.el.TesterFunctions", "void doIt(int)"); + elp.eval("fn:doIt(5)"); + Assert.assertEquals("B", TesterFunctions.getCallList()); + } } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1603576&r1=1603575&r2=1603576&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 18 18:52:58 2014 @@ -246,6 +246,12 @@ via <code>ELProcessor.defineFunction(String,String,String,String)</code> when using Expression Langauge. (markt) </fix> + <fix> + <bug>56638</bug>: When using + <code>ELProcessor.defineFunction(String,String,String,String)</code> and + no function name is specified, use the method name as the function name + as required by the specification. (markt) + </fix> </changelog> </subsection> <subsection name="WebSocket"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org