diff --git a/dolphinscheduler-bom/pom.xml b/dolphinscheduler-bom/pom.xml index 0635239f8c..4e02c347a3 100644 --- a/dolphinscheduler-bom/pom.xml +++ b/dolphinscheduler-bom/pom.xml @@ -360,7 +360,11 @@ jackson-core ${jackson.version} - + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + io.protostuff 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 bfc3af2c58..bae7cb880c 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 @@ -60,6 +60,7 @@ 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 com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.google.common.base.Strings; /** @@ -78,6 +79,7 @@ public final class JSONUtils { .configure(READ_UNKNOWN_ENUM_VALUES_AS_NULL, true) .configure(REQUIRE_SETTERS_FOR_GETTERS, true) .configure(FAIL_ON_EMPTY_BEANS, false) + .addModule(new JavaTimeModule()) .addModule(new SimpleModule() .addSerializer(LocalDateTime.class, new LocalDateTimeSerializer()) .addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer())) diff --git a/dolphinscheduler-dist/release-docs/LICENSE b/dolphinscheduler-dist/release-docs/LICENSE index 1fbd3e6e52..10e22e9b3f 100644 --- a/dolphinscheduler-dist/release-docs/LICENSE +++ b/dolphinscheduler-dist/release-docs/LICENSE @@ -294,7 +294,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt. jackson-core-asl 1.9.13: https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl/1.9.13, Apache 2.0 jackson-databind 2.13.4: https://github.com/FasterXML/jackson-databind, Apache 2.0 jackson-datatype-jdk8 2.13.0: https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.13.0, Apache 2.0 - jackson-datatype-jsr310 2.13.0: https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.13.0, Apache 2.0 + jackson-datatype-jsr310 2.13.4: https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.13.4, Apache 2.0 jackson-mapper-asl 1.9.13: https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl/1.9.13, Apache 2.0 jackson-module-parameter-names 2.13.0: https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-parameter-names/2.13.0, Apache 2.0 javax.jdo-3.2.0-m3: https://mvnrepository.com/artifact/org.datanucleus/javax.jdo/3.2.0-m3, Apache 2.0 diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/model/JSONUtilsTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/model/JSONUtilsTest.java index c17902f568..9ee4a2c0b6 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/model/JSONUtilsTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/model/JSONUtilsTest.java @@ -22,6 +22,9 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -270,4 +273,19 @@ public class JSONUtilsTest { } + @Test + public void toOffsetDateTimeNodeTest() { + TimeZone timeZone = TimeZone.getTimeZone("UTC"); + JSONUtils.setTimeZone(timeZone); + LocalDateTime localDateTime = LocalDateTime.of(2024, 7, 10, 15, 0, 0); + OffsetDateTime offsetDateTime = OffsetDateTime.of(localDateTime, ZoneOffset.ofHours(0)); + Map map = new HashMap<>(); + map.put("time", offsetDateTime); + JsonNode jsonNodes = JSONUtils.toJsonNode(map); + String s = JSONUtils.toJsonString(jsonNodes); + + String json = "{\"time\":\"2024-07-10T15:00:00Z\"}"; + Assertions.assertEquals(json, s); + } + } diff --git a/tools/dependencies/known-dependencies.txt b/tools/dependencies/known-dependencies.txt index 49b2f1367d..7a58095079 100644 --- a/tools/dependencies/known-dependencies.txt +++ b/tools/dependencies/known-dependencies.txt @@ -115,7 +115,7 @@ jackson-databind-2.13.4.jar jackson-dataformat-cbor-2.13.3.jar jackson-dataformat-yaml-2.13.3.jar jackson-datatype-jdk8-2.13.3.jar -jackson-datatype-jsr310-2.13.3.jar +jackson-datatype-jsr310-2.13.4.jar jackson-jaxrs-base-2.13.3.jar jackson-jaxrs-json-provider-2.13.3.jar jackson-mapper-asl-1.9.13.jar