You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by li...@apache.org on 2020/07/02 10:08:04 UTC
[incubator-dolphinscheduler] branch dev updated: [bugfix] fixed
"jackson enum conversion : InvalidFormatException" (#3078)
This is an automated email from the ASF dual-hosted git repository.
lidongdai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new a9eb7b1 [bugfix] fixed "jackson enum conversion : InvalidFormatException" (#3078)
a9eb7b1 is described below
commit a9eb7b18b061d17f5806db0a13a66a0dd0c4a5a7
Author: muzhongjiang <mu...@163.com>
AuthorDate: Thu Jul 2 18:07:57 2020 +0800
[bugfix] fixed "jackson enum conversion : InvalidFormatException" (#3078)
* add state
* fixed bug "jackson enum conversion : InvalidFormatException"
Co-authored-by: mzjnumber1@163.com <mz...@163.com>
Co-authored-by: dailidong <da...@gmail.com>
---
.../dolphinscheduler/common/utils/JSONUtils.java | 42 ++++++++--------------
1 file changed, 15 insertions(+), 27 deletions(-)
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
index 257f202..65a0787 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/JSONUtils.java
@@ -16,33 +16,22 @@
*/
package org.apache.dolphinscheduler.common.utils;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.fasterxml.jackson.databind.type.CollectionType;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.*;
+
+import static com.fasterxml.jackson.databind.DeserializationFeature.*;
/**
@@ -55,17 +44,16 @@ public class JSONUtils {
/**
* can use static singleton, inject: just make sure to reuse!
*/
- private static final ObjectMapper objectMapper = new ObjectMapper();
+ private static final ObjectMapper objectMapper = new ObjectMapper()
+ .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true)
+ .configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true)
+ .setTimeZone(TimeZone.getDefault())
+ ;
private JSONUtils() {
}
- static {
- //Feature that determines whether encountering of unknown properties, false means not analyzer unknown properties
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setTimeZone(TimeZone.getDefault());
- objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT, true).setTimeZone(TimeZone.getDefault());
- }
-
public static ArrayNode createArrayNode() {
return objectMapper.createArrayNode();