Skip to content
New issue

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

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

Already on GitHub? # to your account

dubbo 3.2.x + fastjson2 2.0.48 序列化 属性值丢失 #2411

Closed
Johnson-Jia opened this issue Apr 8, 2024 · 3 comments · Fixed by #2439
Closed

dubbo 3.2.x + fastjson2 2.0.48 序列化 属性值丢失 #2411

Johnson-Jia opened this issue Apr 8, 2024 · 3 comments · Fixed by #2439
Labels
bug Something isn't working fixed
Milestone

Comments

@Johnson-Jia
Copy link

Johnson-Jia commented Apr 8, 2024

dubbo 3.2.x
jdk 8
spring cloud alibaba 2021.0.6
fastjson2 2.0.48

代码如下,结果是courseId 属性值丢失:



@Data
public class RmsFinishCourseDTO implements Serializable {

    private static final long serialVersionUID = -2350411810429763923L;

    @RedisKey
    private String courseId;
    @RedisKey
    private String userId;
    /**
     * 当前学习进度
     */
    private String studyRate;
    /**
     * 资源id
     */
    private String resourceId;
    private String providerCorpCode;
    private String userAgent;

    private String sourceId;

}

        RmsFinishCourseDTO course =new RmsFinishCourseDTO();
        course.setCourseId("6bad799a1c894893bedade17215244a1");
        course.setUserId("4b99d48f87f84868a59aa3b3ce82fd56");

        byte[] bytes = JSONB.toBytes(course, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.FieldBased,
            JSONWriter.Feature.ErrorOnNoneSerializable, JSONWriter.Feature.ReferenceDetection,
            JSONWriter.Feature.WriteNulls, JSONWriter.Feature.NotWriteDefaultValue,
            JSONWriter.Feature.NotWriteHashMapArrayListClassName, JSONWriter.Feature.WriteNameAsSymbol);

        RmsFinishCourseDTO result =
            JSONB.parseObject(bytes, RmsFinishCourseDTO.class, JSONReader.Feature.UseDefaultConstructorAsPossible,
                JSONReader.Feature.ErrorOnNoneSerializable, JSONReader.Feature.IgnoreAutoTypeNotMatch,
                JSONReader.Feature.UseNativeObject, JSONReader.Feature.FieldBased);
        System.out.println(result);

image

@Johnson-Jia Johnson-Jia added the bug Something isn't working label Apr 8, 2024
@Johnson-Jia Johnson-Jia changed the title [BUG] dubbo 3.2.x + fastjson2 2.0.48 序列化 属性值丢失 Apr 8, 2024
@yanxutao89 yanxutao89 self-assigned this Apr 8, 2024
@wenshao
Copy link
Member

wenshao commented Apr 10, 2024

序列化时去掉 JSONWriter.Feature.WriteNameAsSymbol 能先解决问题

@yanxutao89 yanxutao89 removed their assignment Apr 11, 2024
@wenshao wenshao added this to the 2.0.49 milestone Apr 12, 2024
@wenshao wenshao linked a pull request Apr 12, 2024 that will close this issue
@wenshao wenshao added the fixed label Apr 12, 2024
@wenshao
Copy link
Member

wenshao commented Apr 12, 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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants