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]dubbo3.2.11序列化异常 #2392

Closed
pigeon-fancier opened this issue Apr 2, 2024 · 8 comments
Closed

[BUG]dubbo3.2.11序列化异常 #2392

pigeon-fancier opened this issue Apr 2, 2024 · 8 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@pigeon-fancier
Copy link

问题描述

简要描述您碰到的问题。
java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: create instance error class kotlin.collections.EmptyList, offset 3676

环境信息

请填写以下信息:

  • OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB] windows11 32G
  • JDK信息: [e.g.:Openjdk 1.8.0_312] JDK17
  • 版本信息:[e.g.:Fastjson2 2.x.x] Fastjson2 2.0.47 & 2.0.48

重现步骤

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

1.provider lang java
2.consumer lang kotlin
3.混合定义一个实体,比如class Mix{ kotlin class A a, Java class B b}

@pigeon-fancier pigeon-fancier added the bug Something isn't working label Apr 2, 2024
@wenshao wenshao added this to the 2.0.49 milestone Apr 2, 2024
@pigeon-fancier
Copy link
Author

@wenshao 现在有什么办法可以临时解决一下吗,虽然没有上生产,但是最近需要频繁使用

@pigeon-fancier
Copy link
Author

看kotlin的源码是jdk9以上就删除了newInstance这个方法

@wenshao
Copy link
Member

wenshao commented Apr 2, 2024

        Class<?> clazz = Class.forName("kotlin.collections.EmptyList");
        Constructor<?> constructor = clazz.getDeclaredConstructor();
        constructor.setAccessible(true);
        Object object = constructor.newInstance();
        byte[] bytes = JSONB.toBytes(object, JSONWriter.Feature.WriteClassName);
        Object parsed = JSONB.parseObject(bytes, Object.class);

这个是我是能跑过的

wenshao added a commit that referenced this issue Apr 4, 2024
@wenshao wenshao added the fixed label Apr 13, 2024
@wenshao
Copy link
Member

wenshao commented Apr 13, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.49-SNAPSHOT/
问题已经修复,请帮忙用2.0.49-SNAPSHOT版本验证,2.0.49版本预计在明天(4月14日)发布

@wenshao
Copy link
Member

wenshao commented Apr 14, 2024

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

@wenshao wenshao closed this as completed Apr 14, 2024
@pigeon-fancier
Copy link
Author

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

版本2.0.50再次出现,回退到2.0.49依旧解决不了
Caused by: java.lang.IllegalAccessException: class com.alibaba.fastjson2.reader.ObjectReaderImplListStr cannot access a member of class kotlin.collections.EmptyList with modifiers "private"
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:489)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
at java.base/java.lang.Class.newInstance(Class.java:645)
at com.alibaba.fastjson2.reader.ObjectReaderImplListStr.readJSONBObject(ObjectReaderImplListStr.java:145)
... 130 common frames omitted

@wenshao wenshao removed the fixed label May 30, 2024
@wenshao wenshao modified the milestones: 2.0.49, 2.0.51 May 30, 2024
@wenshao wenshao reopened this May 30, 2024
@wenshao
Copy link
Member

wenshao commented May 30, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.51-SNAPSHOT/
问题重新并修复,请帮忙用2.0.51-SNAPSHOT版本验证,2.0.51版本预计本周日(6月2日)发布。

@wenshao
Copy link
Member

wenshao commented Jun 1, 2024

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

@wenshao wenshao closed this as completed Jun 1, 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

2 participants