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

序列化Map与反序列化Map结果不一样 #1819

Closed
rickiehsu opened this issue Aug 31, 2023 · 4 comments
Closed

序列化Map与反序列化Map结果不一样 #1819

rickiehsu opened this issue Aug 31, 2023 · 4 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@rickiehsu
Copy link

问题描述

序列化Map与反序列化Map结果不一样

环境信息

请填写以下信息:

  • JDK信息: [e.g.:jdk 1.8.0_312]
  • 版本信息:[e.g.:Fastjson2 2.0.39]

重现步骤

@Test
    public void testWriteReadMap() throws Exception {
        FrameworkModel frameworkModel = new FrameworkModel();
        Serialization serialization = frameworkModel.getExtensionLoader(Serialization.class).getExtension("fastjson2");
        URL url = URL.valueOf("").setScopeModel(frameworkModel);
        // write map, read map
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ObjectOutput objectOutput = serialization.serialize(url, outputStream);
        Map<String, Object> map = new HashMap<>();
        map.put("work_type", new Integer(1));
        List<Integer> workBys = new ArrayList<>();
        workBys.add(120731003);
        workBys.add(140707005);
        map.put("work_by", workBys);
        objectOutput.writeObject(map);
        objectOutput.flushBuffer();

        byte[] bytes = outputStream.toByteArray();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
        ObjectInput objectInput = serialization.deserialize(url, inputStream);
        map = objectInput.readObject(Map.class);
        workBys = (List) map.get("work_by");
        for (Integer workby : workBys) {
            System.out.println("work_by:" + workby);
        }
    }

反序列化的结果与序列化的值不一样

work_by:1208431157
work_by:1208509188

@rickiehsu rickiehsu added the bug Something isn't working label Aug 31, 2023
@wenshao
Copy link
Member

wenshao commented Sep 3, 2023

构建重现问题的testcase需要相关的类代码,比如FrameworkModel的代码提供下,

@rickiehsu
Copy link
Author

引入一下pom

org.apache.dubbo
dubbo
3.2.5

@rickiehsu
Copy link
Author

引入一下pom

<dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo</artifactId>
            <version>3.2.5</version>
        </dependency>

@wenshao wenshao added this to the 2.0.41 milestone Sep 14, 2023
@wenshao wenshao added the fixed label Oct 5, 2023
@wenshao
Copy link
Member

wenshao commented Oct 6, 2023

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

@wenshao wenshao closed this as completed Oct 6, 2023
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