Skip to content

[QUESTION]升级到fastjson2后针对Classloader对象的序列化行为变动导致异常 #3434

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

Closed
Lo1nt opened this issue Mar 21, 2025 · 2 comments
Labels
bug Something isn't working fixed question Further information is requested
Milestone

Comments

@Lo1nt
Copy link

Lo1nt commented Mar 21, 2025

fastjson升级到fastjson2后write出现异常

输出数据的时候通过JSON.toJSONString(value)实现,升级到fastjson2后由于数据体内有Classloader对象,会导致报错出现stackoverflow(应该是跟classloader对象有关)。

研究了下fastjson会有个特殊处理,当方法返回参数为Classloader.class类型时会跳过该field,就自动不会序列化classloader,业务角度是可以接受的。

com.alibaba.fastjson.util.TypeUtils#computeGetters(java.lang.Class<?>, com.alibaba.fastjson.annotation.JSONType, java.util.Map<java.lang.String,java.lang.String>, java.util.Map<java.lang.String,java.lang.reflect.Field>, boolean, com.alibaba.fastjson.PropertyNamingStrategy)

if(method.getReturnType() == ClassLoader.class){
     continue;
}

看了下fastjson2应该是没有这层过滤逻辑,会输出classloader,这个过滤类型的逻辑考虑加回来吗?

@Lo1nt Lo1nt added the question Further information is requested label Mar 21, 2025
@wenshao wenshao added the bug Something isn't working label Mar 30, 2025
@wenshao wenshao added this to the 2.0.57 milestone Mar 30, 2025
@wenshao
Copy link
Member

wenshao commented Mar 30, 2025

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.57-SNAPSHOT/
问题修复,请帮忙用2.0.57-SNAPSHOT验证,2.0.57版本预计在4月6日前发布

@wenshao
Copy link
Member

wenshao commented Mar 31, 2025

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

@wenshao wenshao closed this as completed Mar 31, 2025
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 question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants