Authored by hugufei

fix json同一个对象的反序列化为null的为题

... ... @@ -3,6 +3,7 @@ package com.yoho.search.cache.beans;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.MD5Util;
import com.yoho.search.cache.model.CacheObject;
... ... @@ -125,7 +126,7 @@ public class SearchCacheService {
public <T> void addSerializableObjectToCache(SearchCache searchCache, RedisKeyBuilder redisKeyBuilder, T object, boolean useJsonSerializable) {
if (useJsonSerializable) {
String jsonStr = JSON.toJSONString(object);
String jsonStr = JSON.toJSONString(object,SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect);
this.addObjectToCache(redisKeyBuilder, jsonStr, searchCache);
} else {
this.addObjectToCache(redisKeyBuilder, object, searchCache);
... ...
... ... @@ -83,7 +83,7 @@ public class RedisCacheUtils {
* @return
*/
private static <T> String serializeToString(T t) {
return JSON.toJSONString(t, SerializerFeature.WriteMapNullValue);
return JSON.toJSONString(t, SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect);
}
private static <T> T unserializeFromString(String cacheObjectValue, Class<T> clazz) {
... ...