[BUG]fastjson1和fastjson2在调用JavaBean里的setXXX()时表现不一致
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:Mac mini M2 pro]
- JDK信息: [e.g.:Openjdk 1.8.0_312]
- 版本信息:[e.g.:Fastjson2 2.0.58]
### 重现步骤
以下代码的输出结果是:
fastjson1: isAd: true
fastjson2: isAd: false
```java
private static class DataTest {
private boolean isAd;
public void setAd(boolean value) {
isAd = value;
}
@Override
public String toString() {
return "isAd: " + isAd;
}
}
public static void main(String[] args) {
String json = "{\"isAd\":true}";
// com.alibaba.fastjson2.JSON.config(JSONReader.Feature.SupportSmartMatch);
System.out.println("fastjson1: " + com.alibaba.fastjson.JSON.parseObject(json, DataTest.class));
System.out.println("fastjson2: " + com.alibaba.fastjson2.JSON.parseObject(json, DataTest.class));
}
```
fastjson2里面必须要添加JSONReader.Feature.SupportSmartMatch标识,才能和fastjson1一样调用setAd()函数,得到和fastjson1一样的结果。但是如果设置了SupportSmartMatch标识,会不会有原本fastjson1调用不到的set方法,被fastjson2"智能"的调用了呢?SupportSmartMatch标识能保证两个fastjson的版本行为一致吗?
Contributor guide
Research direction
Reproduce the Java example with JSON.parseObject for fastjson1 and fastjson2, both with and without JSONReader.Feature.SupportSmartMatch. Trace the JavaBean deserialization entry point to understand how the isAd property maps to setAd(), then add focused regression coverage defining the intended compatibility behavior and verify the outputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100