Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]dubbo自定义Exception中的List类型变量赋值为null时反序列化异常 #2181

Closed
wuyym opened this issue Jan 12, 2024 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@wuyym
Copy link

wuyym commented Jan 12, 2024

问题描述

简要描述您碰到的问题。
dubbo接口抛出自定义的Exception,其中有个变量为List类型的。例如
public class CommonException extends RuntimeException{
Integer code;
String message;
List params;
}

抛出异常信息throw new CommonException(1,"error");
此时params为null。consumer在反序列化CommonException的时候会抛出异常信息:
Caused by: java.lang.NegativeArraySizeException: -1
at com.alibaba.fastjson2.reader.FieldReaderList.readFieldValue(FieldReaderList.java:153)
at com.alibaba.fastjson2.reader.ObjectReaderException.readObject(ObjectReaderException.java:226)
at com.alibaba.fastjson2.reader.ObjectReaderException.readJSONBObject(ObjectReaderException.java:376)
at com.alibaba.fastjson2.JSONB.parseObject(JSONB.java:540)
at org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectInput.readObject(FastJson2ObjectInput.java:122)
at org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectInput.readObject(FastJson2ObjectInput.java:106)
at org.apache.dubbo.common.serialize.ObjectInput.readThrowable(ObjectInput.java:73)

环境信息

请填写以下信息:

  • OS信息: [macOS 13.4]
  • JDK信息: [JDK17]
  • 版本信息:[FastJson 2.0.43][dubbo 3.2.10]

重现步骤

如何操作可以重现该问题:

  1. 抛出自定义的Exception
  2. consumer捕获该异常,在异常反序列化的时候报错。

期待的正确结果

正确反序列化CommonException

相关日志输出

异常堆栈信息在上面已经贴出。

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@wuyym wuyym added the bug Something isn't working label Jan 12, 2024
@wuyym wuyym changed the title [BUG]List对象赋值为null时反序列化异常 [BUG]dubbo自定义Exception中的List类型变量赋值为null时反序列化异常 Jan 12, 2024
@cycle2zhou
Copy link

不为null就能正常,看了源码貌似要么就保持跟RuntimeException的构造器一样,要么你构造器内的参数就不能为空,否则就反序列化不回去了

rowstop added a commit to rowstop/fastjson2 that referenced this issue Jan 13, 2024
@wenshao wenshao added this to the 2.0.46 milestone Jan 13, 2024
rowstop added a commit to rowstop/fastjson2 that referenced this issue Jan 15, 2024
wenshao pushed a commit that referenced this issue Jan 15, 2024
fix jsonb deserialize error on null list field ,for issue #2181
@wenshao wenshao added the fixed label Jan 27, 2024
@wenshao
Copy link
Member

wenshao commented Jan 29, 2024

https://github.com/alibaba/fastjson2/releases/tag/2.0.46
问题已修复,请用新版本

@wenshao wenshao closed this as completed Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants