Skip to content

Commit 38a2f83

Browse files
authored
[Improve][JsonUtils] Use a static object mapper instead of creating it every time (apache#5460)
1 parent 3cfc235 commit 38a2f83

File tree

1 file changed

+4
-2
lines changed
  • seatunnel-common/src/main/java/org/apache/seatunnel/common/utils

1 file changed

+4
-2
lines changed

seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public class JsonUtils {
5959
.configure(REQUIRE_SETTERS_FOR_GETTERS, true)
6060
.setTimeZone(TimeZone.getDefault());
6161

62+
private static final ObjectMapper DEFAULT_OBJECT_MAPPER = new ObjectMapper();
63+
6264
private JsonUtils() {
6365
throw new UnsupportedOperationException("Construct JSONUtils");
6466
}
@@ -172,8 +174,8 @@ public static Map<String, String> toMap(String json) {
172174
}
173175

174176
public static Map<String, Object> toMap(JsonNode jsonNode) {
175-
ObjectMapper mapper = new ObjectMapper();
176-
return mapper.convertValue(jsonNode, new TypeReference<Map<String, Object>>() {});
177+
return DEFAULT_OBJECT_MAPPER.convertValue(
178+
jsonNode, new TypeReference<Map<String, Object>>() {});
177179
}
178180

179181
/**

0 commit comments

Comments
 (0)