Follow-up fix to PR #493
diff --git a/api/src/main/java/jakarta/el/ELProcessor.java b/api/src/main/java/jakarta/el/ELProcessor.java
index e79671d..7a95be0 100644
--- a/api/src/main/java/jakarta/el/ELProcessor.java
+++ b/api/src/main/java/jakarta/el/ELProcessor.java
@@ -118,7 +118,7 @@
      *
      * @param expression The target expression
      * @param value The new value to set.
-     * 
+     *
      * @throws PropertyNotFoundException if one of the property resolutions failed because a specified variable or property
      * does not exist or is not readable.
      * @throws PropertyNotWritableException if the final variable or property resolution failed because the specified
@@ -199,6 +199,9 @@
             if (p < 0) {
                 throw new NoSuchMethodException("Bad method signature: " + method);
             }
+            if (method.substring(p + 1).trim().length() > 0) {
+                throw new NoSuchMethodException("Bad method signature: " + method);
+            }
             String paramString = method.substring(j + 1, p).trim();
             String[] params = paramString.isEmpty() ? new String[0] : paramString.split(",", -1);
             Class<?>[] paramTypes = new Class<?>[params.length];
@@ -228,7 +231,7 @@
      * @param prefix The namespace for the function or "" for no namesapce.
      * @param function The name of the function. If empty (""), the method name is used as the function name.
      * @param method The <code>java.lang.reflect.Method</code> instance of the method that implements the function.
-     * 
+     *
      * @throws NullPointerException if any of the arguments is null.
      * @throws NoSuchMethodException if the method is not a static method
      */
diff --git a/api/src/test/java/jakarta/el/TestELProcessor.java b/api/src/test/java/jakarta/el/TestELProcessor.java
index 0ea9f5c..a2f36ff 100644
--- a/api/src/test/java/jakarta/el/TestELProcessor.java
+++ b/api/src/test/java/jakarta/el/TestELProcessor.java
@@ -16,7 +16,6 @@
 package jakarta.el;
 
 import java.lang.reflect.Method;
-
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
@@ -82,6 +81,13 @@
                 () -> elp.defineFunction("fn", "sum", TestELProcessor.class.getName(), "int sum(int, ,int)"));
     }
 
+    @Test
+    public void testDefineFunctionSignatureEmptyTrailingNonsense() {
+        ELProcessor elp = new ELProcessor();
+        Assertions.assertThrows(NoSuchMethodException.class,
+                () -> elp.defineFunction("fn", "sum", TestELProcessor.class.getName(), "int sum(int,int) nonsense"));
+    }
+
     private static Method resolve(ELProcessor elp, String prefix, String function) {
         return elp.getELManager().getELContext().getFunctionMapper().resolveFunction(prefix, function);
     }