You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "gudegg (GitHub)" <gi...@apache.org> on 2019/01/04 16:23:47 UTC

[GitHub] [incubator-dubbo] gudegg commented on issue #3105: 为什么高版本的dubbo对telnet支持不友好了呢?

这个问题是这个PR引入 https://github.com/apache/incubator-dubbo/commit/27917f2e86bbd97ee047d69817730a57bdf5ad6b
2.5.3
```java
private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
        Invoker<?> invoker = exporter.getInvoker();
        Method[] methods = invoker.getInterface().getMethods();
        for (Method m : methods) {
            if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
                return m;
            }
        }
        return null;
    }
```
之后版本:
```java
   private static Method findMethod(Exporter<?> exporter, String method, List<Object> args) {
        Invoker<?> invoker = exporter.getInvoker();
        Method[] methods = invoker.getInterface().getMethods();
        for (Method m : methods) {
            if (m.getName().equals(method) && isMatch(m.getParameterTypes(), args)) {
                return m;
            }
        }
        return null;
    }
```
新版本导致都会执行`isMatch`,这个方法里面有个逻辑,(ps:telnet传入json格式经过fastjson反序列化后是JsonObject,都会执行下面代码)
```java
else if (arg instanceof Map) {
                String name = (String) ((Map<?, ?>) arg).get("class");
                Class<?> cls = arg.getClass();
                if (name != null && name.length() > 0) {
                    cls = ReflectUtils.forName(name);
                }
                if (!type.isAssignableFrom(cls)) {
                    return false;
                }
            }
```
当用户没有传`class`时,clz就是JsonObject.class 导致直接返回false,最终在不传class时,telnet直接会返回找不到方法;之前老代码在调用重载方法时,用户需要传入class进行参数类型判断,无重载方法时无需传入class;PR这样改正之后,导致所有telnet都必须传入class

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3105 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org