[BUG] parseObject反序列化的Java对象通过不同的classloader加载时,报错
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
parseObject反序列化的Java对象通过不同的classloader加载时,报错
### 环境信息
*请填写以下信息:*
- OS信息: CentOS 8.4.2105 4Core 3.10GHz 32GB
- JDK信息: Openjdk 1.8.0_312
- 版本信息:Fastjson2 2.0.42
### 重现步骤
1、ClassLoader1 加载类 A.class ,并 JSON.parseObject("",A.class);
2、ClassLoader2 加载类 A.class ,并 JSON.parseObject("",A.class); 报错 A.class ClassCastException
### 期待的正确结果
不同的 ClassLoader 加载的类,不应该由于 Fastjson 内部缓存的原因导致序列化失败
### 相关日志输出
无
#### 附加信息
建议优化 Fastjson cache
Contributor guide
Research direction
Start by reproducing the issue with ClassLoader1 and ClassLoader2 loading A.class, then call JSON.parseObject with Fastjson2 2.0.42 and inspect the internal cache involved in class resolution. Done means both deserialization calls succeed without a ClassCastException when equivalent classes come from different classloaders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100