Skip to content

telnet can't work when parameter has no nullary constructor and some fields is primitive #4007

Closed
@fibbery

Description

@fibbery

Environment

  • Dubbo version: 2.6.0
  • Operating System version: macOS 10.14.3
  • Java version: 1.8.0_201

Steps to reproduce this issue

  1. create a class has no nullary constructor and some fields is primitive
public class User implements Serializable {
    private static final long serialVersionUID = -467269449632818122L;
    private int age;
    private String name;
    public User(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
  1. create new method in DemoService
public interface DemoService {
    String sayHello(User user);
}
  1. telnet and invoke this method
invoke sayHello({"age":1,"name":"String","class":"User"})

Expected Result

can invoke successfully

Actual Result

throw exception java.lang.IllegalArgumentException

If there is an exception, please attach the exception trace:

java.lang.IllegalArgumentException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.alibaba.dubbo.common.utils.PojoUtils.newInstance(PojoUtils.java:527)
        at com.alibaba.dubbo.common.utils.PojoUtils.realize0(PojoUtils.java:436)
        at com.alibaba.dubbo.common.utils.PojoUtils.realize(PojoUtils.java:196)
        at com.alibaba.dubbo.common.utils.PojoUtils.realize(PojoUtils.java:86)
        at com.alibaba.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler.telnet(InvokeTelnetHandler.java:138)
        at com.alibaba.dubbo.remoting.telnet.support.TelnetHandlerAdapter.telnet(TelnetHandlerAdapter.java:52)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:181)
        at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:50)
        at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:79)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions