Commit 9018c33d authored by liaozan's avatar liaozan 🏀

Fix possible concurrent issues

parent 67b39843
package com.schbrain.common.util;
import cn.hutool.core.lang.Singleton;
import cn.hutool.extra.spring.SpringUtil;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
......@@ -27,6 +28,7 @@ public class JacksonUtils {
private static ObjectMapper PRETTY_OBJECT_MAPPER;
public static ObjectMapper getObjectMapper() {
return Singleton.get(JacksonUtils.class.getName(), () -> {
if (OBJECT_MAPPER == null) {
// Delay to get ObjectMapper from spring container to keep the same behavior with application
try {
......@@ -38,6 +40,7 @@ public class JacksonUtils {
OBJECT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
return OBJECT_MAPPER;
});
}
public static ObjectMapper getPrettyObjectMapper() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment