Repository: apache/dubbo
File: dubbo-common/src/main/java/org/apache/dubbo/rpc/model/StubServiceDescriptor.java (Java)

Code before:
        return methodModels;
    }

    /**
     * Does not use Optional as return type to avoid potential performance decrease.
     *
     * @param methodName
     * @param params
     * @return
     */
    public MethodDescriptor getMethod(String methodName, String params) {
        Map<String, MethodDescriptor> methods = descToMethods.get(methodName);
        if (CollectionUtils.isNotEmptyMap(methods)) {
            return methods.get(params);
        }
        return null;
    }

    /**
     * Does not use Optional as return type to avoid potential performance decrease.
     *
     * @param methodName
     * @param paramTypes
     * @return
     */
    public MethodDescriptor getMethod(String methodName, Class<?>[] paramTypes) {
        List<MethodDescriptor> methodModels = methods.get(methodName);
        if (CollectionUtils.isNotEmpty(methodModels)) {
            st:
            for (MethodDescriptor descriptor : methodModels) {
                Class<?>[] parameterClasses = descriptor.getParameterClasses();
                int idx = 0;
                // skip params type of StreamObserver, only one param type is StreamObserver should be successful.
                for (Class<?> paramType : paramTypes) {
                    if (paramType.isAssignableFrom(StreamObserver.class)) {
                        continue;
                    }
                    if (paramType != parameterClasses[idx++]) {
                        break st;
                    }
                }
                return descriptor;
            }
        }
        return null;
    }

    public List<MethodDescriptor> getMethods(String methodName) {
        return methods.get(methodName);
    }


Review comment (suggestion):
This is a shared method, and it's not recommended to change it this way.
Just modify https://github.com/apache/dubbo/blob/da8fd19c2c041326f9d35c47b2448e37b35ca716/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/rest/mapping/DefaultRequestMappingRegistry.java#L132
like this should be enough:
```
                    Class<?>[] paramTypes = method.getParameterTypes();
                    MethodDescriptor md = sd.getMethod(method.getName(), paramTypes);
                    if (md == null && sd instanceof StubServiceDescriptor) {
                        int len = paramTypes.length;
                        if (len > 0 && paramTypes[len - 1].isAssignableFrom(StreamObserver.class)) {
                            md = sd.getMethod(method.getName(), Arrays.copyOf(paramTypes, len - 1));
                        }
                    }
```


Code after:
    }

    /**
     * Does not use Optional as return type to avoid potential performance decrease.
     *
     * @param methodName
     * @param params
     * @return
     */
    public MethodDescriptor getMethod(String methodName, String params) {
        Map<String, MethodDescriptor> methods = descToMethods.get(methodName);
        if (CollectionUtils.isNotEmptyMap(methods)) {
            return methods.get(params);
        }
        return null;
    }

    /**
     * Does not use Optional as return type to avoid potential performance decrease.
     *
     * @param methodName
     * @param paramTypes
     * @return
     */
    public MethodDescriptor getMethod(String methodName, Class<?>[] paramTypes) {
        List<MethodDescriptor> methodModels = methods.get(methodName);
        if (CollectionUtils.isNotEmpty(methodModels)) {
            for (MethodDescriptor descriptor : methodModels) {
                if (Arrays.equals(paramTypes, descriptor.getParameterClasses())) {
                    return descriptor;
                }
            }
        }
        return null;
    }

    public List<MethodDescriptor> getMethods(String methodName) {
        return methods.get(methodName);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        StubServiceDescriptor that = (StubServiceDescriptor) o;
        return Objects.equals(interfaceName, that.interfaceName)
                && Objects.equals(serviceInterfaceClass, that.serviceInterfaceClass)