[BUG] 在版本2.0.50中,Object[]数组对象序列化后存入redis缓存,不能取出
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*我们配置了redis的hash存储的GenericFastJsonRedisSerializer序列化,我们在存入缓存的时候可以通过这个序列化存入,但是取出来的时候只能拿到一个@value*
### 环境信息
*本地调试*
- OS信息: windows11 cpu=4 men=16GB
- JDK信息:1.8
- 版本信息:Fastjson2 2.0.50
### 重现步骤
*存入的内容格式,如下:*
```json
{
"@type": "[com.xxx.ProtocolParamEntity",
"@value": [
{
"id": "1",
"bit": "0"
},
{
"id": "2",
"bit": "1"
},
null,
null
]
}
```
*数据存入到redis之后,通过hash取出来,到obj对象,但是这个对象的值是@value,根本无法转换成ProtocolParamEntity[]*
```java
private ProtocolParamEntity[] getHash(String protocolId, String address) {
String hash = PhnixConstants.CACHE_PROTOCAL_PARAM_PREFIX + protocolId;
Object obj = redisDataBase.db0().getOpsForHashValue(hash, address);
if (null == obj) {
return new ProtocolParamEntity[0];
}
return (ProtocolParamEntity[])obj;
}
```
### 期待的正确结果
**能够正常取出
### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*
Contributor guide
Research direction
Start by reproducing the Object[] round trip with GenericFastJsonRedisSerializer, Fastjson2 2.0.50, and the Redis hash access shown in the issue. Inspect how the serialized @type/@value representation is deserialized when null elements are present. Add a regression test for ProtocolParamEntity[] and confirm that retrieving the hash value returns the expected array rather than an object exposing @value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100