[FEATURE] 未知异常:java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.nc.statistics.dto.response.CarStatisticalDTO
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
springcloudalibaba, java8,redis3;
redis中的旧数据
{
"@type": "com.nc.statistics.dto.response.CarStatisticalDTO",
"abnormalTypeName": false,
"accountBalance": false
};
fastjson1.2.83 升级到 fastjson2.0.61后,
直接替换为 fastjson-2.0.61.jar,fastjson2-2.0.61.jar,fastjson2-extension-2.0.61.jar
接口取redis中的旧数据,提示未知异常:java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.nc.statistics.dto.response.CarStatisticalDTO;
请问有什么方式,可以兼容这种旧数据。
Contributor guide
Research direction
Reproduce the failure using the listed Java 8, Redis 3, fastjson 1.2.83/2.0.61 versions and the supplied legacy JSON. Start by tracing how fastjson2 reads the Redis value and handles the @type field, then compare the resulting object with CarStatisticalDTO. Done means the compatibility behavior for this old record is verified and either supported by a test or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100