another problem,if a method contains complex parameters,Such as class Student 
below,the invoke command can never invoke the correct method since 
com.alibaba.fastjson.JSON#parseArray(java.lang.String, java.lang.Class<T>) can 
not parse args to correct class,in blow method to parse the args 
(com.alibaba.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler#telnet; list = 
JSON.parseArray("[" + args + "]", Object.class);)
```
public String telnet(Channel channel, String message) {
        if (message == null || message.length() == 0) {
            return "Please input method name, eg: \r\ninvoke xxxMethod(1234, 
\"abcd\", {\"prop\" : \"value\"})\r\ninvoke XxxService.xxxMethod(1234, 
\"abcd\", {\"prop\" : \"value\"})\r\ninvoke com.xxx.XxxService.xxxMethod(1234, 
\"abcd\", {\"prop\" : \"value\"})";
        }
        StringBuilder buf = new StringBuilder();
        String service = (String) 
channel.getAttribute(ChangeTelnetHandler.SERVICE_KEY);
        if (service != null && service.length() > 0) {
            buf.append("Use default service " + service + ".\r\n");
        }
        int i = message.indexOf("(");
        if (i < 0 || !message.endsWith(")")) {
            return "Invalid parameters, format: service.method(args)";
        }
        String method = message.substring(0, i).trim();
        String args = message.substring(i + 1, message.length() - 1).trim();
        i = method.lastIndexOf(".");
        if (i >= 0) {
            service = method.substring(0, i).trim();
            method = method.substring(i + 1).trim();
        }
        List<Object> list;
        try {
            list = JSON.parseArray("[" + args + "]", Object.class);
        } catch (Throwable t) {
            return "Invalid json argument, cause: " + t.getMessage();
        }
...
}
```

```
public class Student implements Serializable {
    private String name;
    private Integer age;
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

}
```
,not like the [Telnet Command 
Reference](https://dubbo.incubator.apache.org/en-us/docs/user/references/telnet.html)
 decribed about the invoke command.So I think there is necessary to enhance the 
invoke command and make the argument type known to it.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to