Skip to content

Commit b9d09cc

Browse files
authored
[core]: RESTCatalog: use object mapper from JsonSerdeUtil in RESTObjectMapper (#5354)
1 parent add377c commit b9d09cc

File tree

3 files changed

+8
-34
lines changed

3 files changed

+8
-34
lines changed

docs/content/flink/procedures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ All available procedures are listed below.
809809
CALL [catalog.]sys.alter_view_dialect('view_identifier', 'update', 'flink', 'query')<br/>
810810
CALL [catalog.]sys.alter_view_dialect(`view` => 'view_identifier', `action` => 'update', `query` => 'query')<br/><br/>
811811
-- drop dialect in the view<br/>
812-
CALL [catalog.]sys.alter_view_dialect('view_identifier', 'drop', 'flink')<br/><br/>
812+
CALL [catalog.]sys.alter_view_dialect('view_identifier', 'drop', 'flink')<br/>
813813
CALL [catalog.]sys.alter_view_dialect(`view` => 'view_identifier', `action` => 'drop')<br/><br/>
814814
</td>
815815
<td>

paimon-core/src/main/java/org/apache/paimon/rest/RESTObjectMapper.java

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,12 @@
1818

1919
package org.apache.paimon.rest;
2020

21-
import org.apache.paimon.types.DataField;
22-
import org.apache.paimon.types.DataType;
23-
import org.apache.paimon.types.DataTypeJsonParser;
21+
import org.apache.paimon.utils.JsonSerdeUtil;
2422

25-
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.DeserializationFeature;
26-
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.Module;
2723
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
28-
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.SerializationFeature;
29-
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.module.SimpleModule;
30-
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
31-
32-
import static org.apache.paimon.utils.JsonSerdeUtil.registerJsonObjects;
3324

3425
/** Object mapper for REST request and response. */
3526
public class RESTObjectMapper {
3627

37-
public static final ObjectMapper OBJECT_MAPPER = RESTObjectMapper.create();
38-
39-
private static ObjectMapper create() {
40-
ObjectMapper mapper = new ObjectMapper();
41-
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
42-
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
43-
mapper.registerModule(createPaimonRestJacksonModule());
44-
mapper.registerModule(new JavaTimeModule());
45-
return mapper;
46-
}
47-
48-
private static Module createPaimonRestJacksonModule() {
49-
SimpleModule module = new SimpleModule("Paimon_REST");
50-
registerJsonObjects(
51-
module,
52-
DataField.class,
53-
DataField::serializeJson,
54-
DataTypeJsonParser::parseDataField);
55-
registerJsonObjects(
56-
module, DataType.class, DataType::serializeJson, DataTypeJsonParser::parseDataType);
57-
return module;
58-
}
28+
public static final ObjectMapper OBJECT_MAPPER = JsonSerdeUtil.OBJECT_MAPPER_INSTANCE;
5929
}

paimon-core/src/main/java/org/apache/paimon/utils/JsonSerdeUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
3030
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.core.type.TypeReference;
3131
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.DeserializationContext;
32+
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.DeserializationFeature;
3233
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.JsonNode;
3334
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.Module;
3435
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
36+
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.SerializationFeature;
3537
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.SerializerProvider;
3638
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.deser.std.StdDeserializer;
3739
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.module.SimpleModule;
@@ -53,10 +55,12 @@ public class JsonSerdeUtil {
5355
* Object mapper shared instance to serialize and deserialize the plan. Note that creating and
5456
* copying of object mappers is expensive and should be avoided.
5557
*/
56-
private static final ObjectMapper OBJECT_MAPPER_INSTANCE;
58+
public static final ObjectMapper OBJECT_MAPPER_INSTANCE;
5759

5860
static {
5961
OBJECT_MAPPER_INSTANCE = new ObjectMapper();
62+
OBJECT_MAPPER_INSTANCE.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
63+
OBJECT_MAPPER_INSTANCE.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
6064
OBJECT_MAPPER_INSTANCE.registerModule(createPaimonJacksonModule());
6165
OBJECT_MAPPER_INSTANCE.registerModule(new JavaTimeModule());
6266
}

0 commit comments

Comments
 (0)