This is an automated email from the ASF dual-hosted git repository.

gaojun2048 pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 38a2f837b2 [Improve][JsonUtils] Use a static object mapper instead of 
creating it every time (#5460)
38a2f837b2 is described below

commit 38a2f837b25ef1b16cbe06de00d18f270aa78c68
Author: Morssssy <[email protected]>
AuthorDate: Mon Sep 18 16:44:45 2023 +0800

    [Improve][JsonUtils] Use a static object mapper instead of creating it 
every time (#5460)
---
 .../src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java  | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java
 
b/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java
index 181d035556..9a3dbe39d1 100644
--- 
a/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java
+++ 
b/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java
@@ -59,6 +59,8 @@ public class JsonUtils {
                     .configure(REQUIRE_SETTERS_FOR_GETTERS, true)
                     .setTimeZone(TimeZone.getDefault());
 
+    private static final ObjectMapper DEFAULT_OBJECT_MAPPER = new 
ObjectMapper();
+
     private JsonUtils() {
         throw new UnsupportedOperationException("Construct JSONUtils");
     }
@@ -172,8 +174,8 @@ public class JsonUtils {
     }
 
     public static Map<String, Object> toMap(JsonNode jsonNode) {
-        ObjectMapper mapper = new ObjectMapper();
-        return mapper.convertValue(jsonNode, new TypeReference<Map<String, 
Object>>() {});
+        return DEFAULT_OBJECT_MAPPER.convertValue(
+                jsonNode, new TypeReference<Map<String, Object>>() {});
     }
 
     /**

Reply via email to