apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.54k stars 26.44k forks source link

[Bug] java.util.ArrayList cannot be assigned to 'java.util.List' #14668

Open luo-zhan opened 2 months ago

luo-zhan commented 2 months ago

Pre-check

Search before asking

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

dubbo 3.0.11 jdk 1.8 mac 14.2

Steps to reproduce this issue

When provider throw a custom exception, then consumer get a exception :

org.apache.dubbo.rpc.RpcException: Failfast invoke providers DefaultServiceInstance{serviceName='bss-security-service', host='10.73.195.73', ....}, cause: org.apache.dubbo.remoting.RemotingException: com.alibaba.com.caucho.hessian.io.HessianFieldException: java.lang.Throwable.suppressedExceptions: java.util.ArrayList cannot be assigned to 'java.util.List'
com.alibaba.com.caucho.hessian.io.HessianFieldException: java.lang.Throwable.suppressedExceptions: java.util.ArrayList cannot be assigned to 'java.util.List'
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:172)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer.deserialize(JavaDeserializer.java:534)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:277)
    ...
Caused by: java.lang.IllegalAccessException: class com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer cannot access a member of class java.lang.Throwable (in module java.base) with modifiers "private"
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
    at java.base/java.lang.reflect.Field.checkAccess(Field.java:1140)
    at java.base/java.lang.reflect.Field.set(Field.java:817)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer.deserialize(JavaDeserializer.java:532)
    ... 81 more

Caused by: java.util.concurrent.ExecutionException: org.apache.dubbo.remoting.RemotingException: com.alibaba.com.caucho.hessian.io.HessianFieldException: java.lang.Throwable.suppressedExceptions: java.util.ArrayList cannot be assigned to 'java.util.List'
com.alibaba.com.caucho.hessian.io.HessianFieldException: java.lang.Throwable.suppressedExceptions: java.util.ArrayList cannot be assigned to 'java.util.List'
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:172)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer.deserialize(JavaDeserializer.java:534)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:277)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:204)
    at com.alibaba.com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:548)
...
Caused by: java.lang.IllegalAccessException: class com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer cannot access a member of class java.lang.Throwable (in module java.base) with modifiers "private"
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
    at java.base/java.lang.reflect.Field.checkAccess(Field.java:1140)
    at java.base/java.lang.reflect.Field.set(Field.java:817)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer.deserialize(JavaDeserializer.java:532)
    ...
Caused by: org.apache.dubbo.remoting.RemotingException: com.alibaba.com.caucho.hessian.io.HessianFieldException: java.lang.Throwable.suppressedExceptions: java.util.ArrayList cannot be assigned to 'java.util.List'
com.alibaba.com.caucho.hessian.io.HessianFieldException: java.lang.Throwable.suppressedExceptions: java.util.ArrayList cannot be assigned to 'java.util.List'
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:172)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer.deserialize(JavaDeserializer.java:534)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:277)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:204)
    at com.alibaba.com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:548)
    at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2850)
...
Caused by: java.lang.IllegalAccessException: class com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer cannot access a member of class java.lang.Throwable (in module java.base) with modifiers "private"
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394)
    at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
    at java.base/java.lang.reflect.Field.checkAccess(Field.java:1140)
    at java.base/java.lang.reflect.Field.set(Field.java:817)
    at com.alibaba.com.caucho.hessian.io.JavaDeserializer$ObjectListFieldDeserializer.deserialize(JavaDeserializer.java:532)
    ... 81 more

What you expected to happen

A right exception or tips.

Anything else

dubbo service method: BaseResponseDTO changeSecurityStatus(Integer market, String securityCode, Integer securityStatus);

consumer throws custom exception:

package com.hst.arch.components.exception.types;

import com.hst.arch.components.exception.AbstractHSTBaseException;

public class HSTAlertingBaseException extends AbstractHSTBaseException {
    public HSTAlertingBaseException(String code, String msg, Object... args) {
        super(code, msg, args);
    }
}

Are you willing to submit a pull request to fix on your own?

Code of Conduct

JunJieLiu51520 commented 2 months ago

can you show your consumer and provider initialized config or simple demo ?

furthermore, why jdk8 has java.base ?

JunJieLiu51520 commented 2 months ago

i can't reproduce

heliang666s commented 1 month ago

This might be an issue with Hessian serialization. You could try switching to a different serialization method, such as Protobuf or FastJSON.@luo-zhan

wcy666103 commented 1 month ago

Try to upgrade to high version dubbo such as 3.3.1, this is a Hessian-Lite related bug. And the same error message https://github.com/apache/dubbo/issues/14791 to this problem

AlbumenJ commented 1 month ago

You JDK version should not be 1.8. java.base/jdk.internal.reflect.Reflection.newIllegalAccessException only happends on JDK17 and above.