This is an automated email from the ASF dual-hosted git repository. shaofengshi pushed a commit to branch 3.0.x in repository https://gitbox.apache.org/repos/asf/kylin.git
commit eb43eeb3245caf87210c0d2fb820c62193a0542f Author: shaofengshi <[email protected]> AuthorDate: Sat Aug 15 15:28:24 2020 +0800 Revert "KYLIN-4543 Remove the usage for jackson enableDefaultTyping()" This reverts commit a3df4f3bf69e3910aecb486e953332fbb9dd0c95. --- .../src/main/java/org/apache/kylin/common/util/JsonUtil.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core-common/src/main/java/org/apache/kylin/common/util/JsonUtil.java b/core-common/src/main/java/org/apache/kylin/common/util/JsonUtil.java index 1a8e7cc..8cb7f65 100644 --- a/core-common/src/main/java/org/apache/kylin/common/util/JsonUtil.java +++ b/core-common/src/main/java/org/apache/kylin/common/util/JsonUtil.java @@ -45,10 +45,12 @@ public class JsonUtil { // reuse the object mapper to save memory footprint private static final ObjectMapper mapper = new ObjectMapper(); private static final ObjectMapper indentMapper = new ObjectMapper(); + private static final ObjectMapper typeMapper = new ObjectMapper(); static { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); indentMapper.configure(SerializationFeature.INDENT_OUTPUT, true); + typeMapper.enableDefaultTyping(); } public static <T> T readValue(File src, Class<T> valueType) @@ -91,6 +93,10 @@ public class JsonUtil { return mapper.readTree(content); } + public static <T> T readValueWithTyping(InputStream src, Class<T> valueType) throws IOException { + return typeMapper.readValue(src, valueType); + } + public static void writeValueIndent(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { indentMapper.writeValue(out, value); @@ -112,4 +118,8 @@ public class JsonUtil { public static String writeValueAsIndentString(Object value) throws JsonProcessingException { return indentMapper.writeValueAsString(value); } + + public static void writeValueWithTyping(OutputStream out, Object value) throws IOException { + typeMapper.writeValue(out, value); + } } \ No newline at end of file
