[BUG]2.0.54版本,使用parseObject(String text, Class<T> clazz)方法导致OOM
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
parseObject生成大量值为null的对象,导致内存突然之间飚高,最终OOM
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
- JDK信息: [e.g.:Openjdk 21.xxx]
- 版本信息:[e.g.:Fastjson2 2.0.54]
### 重现步骤
*如何操作可以重现该问题:*
执行如下代码可以复现
```java
@Getter
@Setter
public class User {
private List schools;
public static void main(String[] args) throws JsonProcessingException {
User entity = JSON.parseObject("{\"schools\":[{nu}]}", User.class, JSONReader.Feature.IgnoreNullPropertyValue);
System.out.println(entity);
}
@Getter
@Setter
static class School {
private String name;
}
}
```
### 期待的正确结果
*不OOM*
### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
#### 附加信息
Contributor guide
Research direction
Start with the provided User/School reproducer and trace JSON.parseObject(String, Class, JSONReader.Feature.IgnoreNullPropertyValue), focusing on the schools list and malformed null values. Confirm the behavior with a focused regression test; done means parsing the input no longer creates unbounded null-valued objects or causes OOM.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100