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

[GitHub] [incubator-dubbo] qq925716471 opened issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

-  I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
-  I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 2.7.0
* Operating System version: Ubuntu18.04
* Java version: jdk8
 1. dubbo-ops with dubbo 2.7.0 and other appication use old version. 
 2. Copy MonitorService from old version to dubbo-ops.
 3. Other application send url call com.alibaba.dubbo.monitor.MonitorService#collect(URL statistics).

result:
 WARN dubbo.DecodeableRpcInvocation -  [DUBBO] Decode argument failed: 'com.alibaba.dubbo.common.URL' could not be instantiated, dubbo version: 2.7.0-SNAPSHOT, current host: 10.236.105.240
com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

[https://github.com/ebourg/hessian/blob/git-svn/src/com/caucho/hessian/io/JavaDeserializer.java](url)
`for (int i = 0; i < constructors.length; i++) {
      Class<?> []param = constructors[i].getParameterTypes();
      long cost = 0;

      for (int j = 0; j < param.length; j++) {
        cost = 4 * cost;

        if (Object.class.equals(param[j]))
          cost += 1;
        else if (String.class.equals(param[j]))
          cost += 2;
        else if (int.class.equals(param[j]))
          cost += 3;
        else if (long.class.equals(param[j]))
          cost += 4;
        else if (param[j].isPrimitive())
          cost += 5;
        else
          cost += 6;
      }

      if (cost < 0 || cost > (1 << 48))
        cost = 1 << 48;

      cost += (long) param.length << 48;

      if (cost < bestCost) {
        _constructor = constructors[i];
        bestCost = cost;
      }
    }
    if (_constructor != null) {
      _constructor.setAccessible(true);
      Class<?> []params = _constructor.getParameterTypes();
      _constructorArgs = new Object[params.length];
      for (int i = 0; i < params.length; i++) {
        _constructorArgs[i] = getParamArg(params[i]);
      }
    }`

[https://github.com/apache/incubator-dubbo/blob/master/dubbo-compatible/src/main/java/com/alibaba/dubbo/common/URL.java](url)
the bestcost constructor is this one;
` public URL(org.apache.dubbo.common.URL url) {
        super(url.getProtocol(), url.getUsername(), url.getPassword(), url.getHost(), url.getPort(), url.getPath(), url.getParameters());
    }`

and _constructorArgs[0] is null 
when run at  _constructor.newInstance(_constructorArgs) application throw NullPointerException

```
Caused by: java.lang.reflect.InvocationTargetException
	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.com.caucho.hessian.io.JavaDeserializer.instantiate(JavaDeserializer.java:312)
	... 32 more
Caused by: java.lang.NullPointerException
	at com.alibaba.dubbo.common.URL.<init>(URL.java:30)
```


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


[GitHub] [incubator-dubbo] carryxyh commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "carryxyh (GitHub)" <gi...@apache.org>.
We should involve more people in the community, unless the person asking the question does not intend to submit the pr, otherwise we should encourage the person asking the question to submit the pr, especially those who have never participated in the community.

Why don't I deal your pr? good question. I would like to ask you, why not encourage the person who made this issue to submit pr to fix his own question?

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


[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
@carryxyh 
Why not deal with my PR?

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


[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
Then I want to ask you, I solve this problem is to encourage others to solve it? Someone raised a question. If you have been waiting for the person who asked the question to solve it, should the obvious problem be backlogged?
There are many ways to participate in the community, and asking questions is also a way to participate in the community. I think I just saw this problem and felt that it could be solved, then I submitted the changes, and in exchange for being ignored, and understood to discourage others from solving the problem. If you need to wait for someone to ask a question, then how long do you think it will be reasonable? Then I know now, to deal with other people's problems is to discourage others from solving their own problems.

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


[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
You are right!it must keep a no-argument constructor method in URL.java. I will submit a PR to fix it.

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

[GitHub] [incubator-dubbo] CrazyHZM commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "CrazyHZM (GitHub)" <gi...@apache.org>.
I have already submitted a pr.
So I should close my pr , right?

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


[GitHub] [incubator-dubbo] carryxyh commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "carryxyh (GitHub)" <gi...@apache.org>.
You misunderstood what I meant. This is a very simple little problem and it is not urgent to be fixed. In this case, I asked the submitter of this issue.

I just checked your two prs, I think @qq925716471 's pr is better, for specific reasons pls check the comments under https://github.com/apache/incubator-dubbo/pull/3350.

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


[GitHub] [incubator-dubbo] carryxyh closed issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "carryxyh (GitHub)" <gi...@apache.org>.
[ issue closed by carryxyh ]

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


[GitHub] [incubator-dubbo] qq925716471 commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "qq925716471 (GitHub)" <gi...@apache.org>.
It should keep the no-argument constructor method.

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


[GitHub] [incubator-dubbo] carryxyh commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "carryxyh (GitHub)" <gi...@apache.org>.
@qq925716471 
Thx for your contribution.

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


[GitHub] [incubator-dubbo] carryxyh commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "carryxyh (GitHub)" <gi...@apache.org>.
@qq925716471 
I noticed that you have not submitted a pull request. Would you like to try to submit a pull request to fix the problem you found yourself?

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


[GitHub] [incubator-dubbo] Bricks-Man commented on issue #3342: dubbo2.7.0 com.alibaba.com.caucho.hessian.io.HessianProtocolException: 'com.alibaba.dubbo.common.URL' could not be instantiated

Posted by "Bricks-Man (GitHub)" <gi...@apache.org>.
Yeah, in Hessian, you must keep a no-argument constructor method.

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