This is an automated email from the ASF dual-hosted git repository.

amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git

commit 3ba0257e96f7e43f6d859f1e000e6df8eb3f79f0
Author: Amichai Rothman <amic...@apache.org>
AuthorDate: Sun Jun 29 16:46:23 2025 +0300

    Refactor MethodInvoker.getMethod
---
 .../java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
 
b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
index 12a933eb..65d625f6 100644
--- 
a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
+++ 
b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Reflectively invokes the methods of a service object
@@ -30,7 +31,7 @@ import java.util.List;
  */
 public class MethodInvoker {
 
-    private HashMap<Object, Object> primTypes;
+    private Map<Object, Object> primTypes;
     private Object service;
     private Class<?>[] interfaces;
 
@@ -93,15 +94,14 @@ public class MethodInvoker {
 
     private Method getMethod(String methodName, Class<?>[] parameterTypesAr) 
throws NoSuchMethodException {
         try {
+            // fast path - exact match
             Method method = service.getClass().getMethod(methodName, 
parameterTypesAr);
             return verifyInterface(method);
         } catch (NoSuchMethodException e) {
+            // fallback - search all methods for name, params count, 
assignable param types, null values, etc.
             Method[] methods = service.getClass().getMethods();
             for (Method method : methods) {
-                if (!method.getName().equals(methodName)) {
-                    continue;
-                }
-                if (allParamsMatch(method.getParameterTypes(), 
parameterTypesAr)) {
+                if (method.getName().equals(methodName) && 
allParamsMatch(method.getParameterTypes(), parameterTypesAr)) {
                     return verifyInterface(method);
                 }
             }

Reply via email to