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

JSONObject.parseObject 解析字符串时,遇到 [null] 时堆内存溢出 #4516

Open
liushuangSRD opened this issue Jul 10, 2024 · 1 comment

Comments

@liushuangSRD
Copy link

liushuangSRD commented Jul 10, 2024

属性类:
`
public class Field {

private String id;

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

}
`

转换测试类

`
public class Test {

class HeapSpace{

    private List<Field> reportOwner;

    public List<Field> getReportOwner() {
        return reportOwner;
    }

    public void setReportOwner(List<Field> reportOwner) {
        this.reportOwner = reportOwner;
    }

}

public static void main(String[] args) {
    String parseString = "{\"reportOwner\":[null]}";
    HeapSpace heapSpace = JSONObject.parseObject(parseString, HeapSpace.class);
    String aa = "";
}

}
`

执行后内存一直飙升,直到堆内存溢出,生产环境报错
Handler dispatch failed; nested exception is java.lang.OutOfMemoryError: Java heap space

@liushuangSRD liushuangSRD changed the title JSONObject.parseObject 在解析字符串,在遇到 [null] 时堆内存溢出 JSONObject.parseObject 解析字符串时,遇到 [null] 时堆内存溢出 Jul 10, 2024
@kimmking
Copy link
Contributor

HeapSpace作为一个内部类,如果没有static,无法访问。
加上static后,解析正常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants