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]应该为null的List解析成ArrayList然后往里面添加一个null的item #525

Closed
Coloryr opened this issue Jul 2, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@Coloryr
Copy link

Coloryr commented Jul 2, 2022

直接上图看吧
QA)EB0 X@9)5WI`}U@ A{CY
2.0.6无此问题
2.0.8问题依旧存在

@Coloryr Coloryr added the bug Something isn't working label Jul 2, 2022
@Coloryr Coloryr changed the title [BUG] [BUG]List解析成ArrayList然后往里面添加一个null的项目 Jul 2, 2022
@Coloryr
Copy link
Author

Coloryr commented Jul 2, 2022

@Coloryr Coloryr changed the title [BUG]List解析成ArrayList然后往里面添加一个null的项目 [BUG]应该为null的List解析成ArrayList然后往里面添加一个null的项目 Jul 2, 2022
@Coloryr Coloryr changed the title [BUG]应该为null的List解析成ArrayList然后往里面添加一个null的项目 [BUG]应该为null的List解析成ArrayList然后往里面添加一个null的item Jul 2, 2022
@wenshao wenshao added this to the 2.0.9 milestone Jul 3, 2022
@wenshao
Copy link
Member

wenshao commented Jul 3, 2022

没重现问题,测试代码如下:

package com.alibaba.fastjson2.issues;

import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

public class Issue525 {
    @Test
    public void test() {
        String str = "{\"qq\":123456789,\"name\":\"xxx\",\"req\":null,\"groups\":null,\"qqList\":null}";
        StartPack startPack = JSON.parseObject(str, StartPack.class);
        assertEquals(123456789, startPack.qq);
        assertEquals("xxx", startPack.name);
        assertNull(startPack.reg);
        assertNull(startPack.groups);
        assertNull(startPack.qqList);
    }

    public static class StartPack
            extends PackBase {
        /**
         * 插件名字
         */
        public String name;
        /**
         * 注册的事件
         */
        public List<Integer> reg;
        /**
         * 监听QQ群列表
         */
        public List<Long> groups;
        /**
         * 监听QQ号列表
         */
        public List<Long> qqList;
    }

    public abstract static class PackBase {
        /*
         * 运行QQ号
         */
        public long qq;
    }
}

wenshao added a commit that referenced this issue Jul 3, 2022
wenshao added a commit that referenced this issue Jul 3, 2022
@Zhuoyuan1
Copy link

Zhuoyuan1 commented Jul 4, 2022

发布的2.0.8版本,确有该问题,但main分支好像修复了
image

@wenshao
Copy link
Member

wenshao commented Jul 4, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.9-SNAPSHOT/
问题已修复,请用2.0.9-SNAPSHOT验证,2.0.9预计在7月10日前发布

@wenshao
Copy link
Member

wenshao commented Jul 10, 2022

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

@wenshao wenshao closed this as completed Jul 10, 2022
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

3 participants