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反序列化出现UnsupportedOperationException #2734

Closed
nieqiurong opened this issue Jun 25, 2024 · 1 comment
Closed

[BUG] Dubbo反序列化出现UnsupportedOperationException #2734

nieqiurong opened this issue Jun 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nieqiurong
Copy link

问题描述

Dubbo反序列化时使用了JSONReader.Feature.FieldBased导致UnsupportedOperationException

环境信息

  • OS信息: win11
  • JDK信息: 21
  • 版本信息:2.0.51

重现步骤

如何操作可以重现该问题:
模型属性定义默认Collections.emptyList()值;

    public static void main(String[] args) {
        Page<String> page = new Page<>();
        List<String> data = new ArrayList<>();
        data.add("1234");
        page.setData(data);
        byte[] bytes = JSONB.toBytes(page);
        Page page1 = JSONB.parseObject(bytes, Page.class, JSONReader.Feature.FieldBased);
        System.out.println(page1);
    }

    public static class Page<T> {

        private List<T> data = Collections.emptyList();

        public void setData(List<T> items) {
            this.data = items;
        }

        public List<T> getData() {
            return data;
        }
    }

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。

相关日志输出

Exception in thread "main" java.lang.UnsupportedOperationException
at java.base/java.util.AbstractList.add(AbstractList.java:155)
at java.base/java.util.AbstractList.add(AbstractList.java:113)
at com.alibaba.fastjson2.reader.ORG_1_1_Page.readJSONBObject(Unknown Source)
at com.alibaba.fastjson2.JSONB.parseObject(JSONB.java:799)
at com.baomidou.mybatisplus.test.App.main(App.java:18)

附加信息

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

@rowstop
Copy link
Contributor

rowstop commented Jun 25, 2024

已经修复了 #2691

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

No branches or pull requests

2 participants