[BUG]
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*在模块一中序列化数据,写入到redis当中。用模块二读取出来发现反序列化失败*
Redis设置的序列化器代码如下:
``` java
public class FastJson2JsonRedisSerializer implements RedisSerializer
{
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
private Class clazz;
public FastJson2JsonRedisSerializer(Class clazz)
{
super();
this.clazz = clazz;
}
@Override
public byte[] serialize(T t) throws SerializationException
{
if (t == null)
{
return new byte[0];
}
return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
}
@Override
public T deserialize(byte[] bytes) throws SerializationException
{
if (bytes == null || bytes.length <= 0)
{
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
}
}
``` java
疑似是序列化会携带@type类似的字段,导致序列化失败
### 环境信息
*请填写以下信息:*
- fastjson2版本:2.0.57
Contributor guide
Research direction
Start by reproducing the cross-module Redis round trip with fastjson2 2.0.57 using the provided FastJson2JsonRedisSerializer, then inspect the serialized data for the suspected @type field and record the deserialization error. Done means data written by one module can be read and deserialized successfully by the other.
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
- 42/100