|
|
@@ -6,6 +6,8 @@ import org.springframework.data.redis.serializer.SerializationException;
|
|
6
|
6
|
import com.alibaba.fastjson2.JSON;
|
|
7
|
7
|
import com.alibaba.fastjson2.JSONReader;
|
|
8
|
8
|
import com.alibaba.fastjson2.JSONWriter;
|
|
|
9
|
+import com.alibaba.fastjson2.filter.Filter;
|
|
|
10
|
+import com.ruoyi.common.core.constant.Constants;
|
|
9
|
11
|
|
|
10
|
12
|
/**
|
|
11
|
13
|
* Redis使用FastJson序列化
|
|
|
@@ -16,8 +18,9 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|
16
|
18
|
{
|
|
17
|
19
|
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
|
18
|
20
|
|
|
19
|
|
- private Class<T> clazz;
|
|
|
21
|
+ static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR);
|
|
20
|
22
|
|
|
|
23
|
+ private Class<T> clazz;
|
|
21
|
24
|
|
|
22
|
25
|
public FastJson2JsonRedisSerializer(Class<T> clazz)
|
|
23
|
26
|
{
|
|
|
@@ -44,6 +47,6 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
|
44
|
47
|
}
|
|
45
|
48
|
String str = new String(bytes, DEFAULT_CHARSET);
|
|
46
|
49
|
|
|
47
|
|
- return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
|
|
50
|
+ return JSON.parseObject(str, clazz, AUTO_TYPE_FILTER);
|
|
48
|
51
|
}
|
|
49
|
52
|
}
|