Skip to content

Commit 7fced29

Browse files
committed
refactor
1 parent a4f5d95 commit 7fced29

7 files changed

Lines changed: 7 additions & 36 deletions

File tree

common/src/main/java/org/apache/drill/common/util/JacksonUtils.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static JsonMapper.Builder createJsonMapperBuilder() {
5757
// org.apache.drill.metastore.statistics.StatisticsHolder replaces this with
5858
// a polymorphicTypeValidator that allows only the types it needs
5959
return JsonMapper.builder()
60-
.polymorphicTypeValidator(BasicPolymorphicTypeValidator.builder().build());
60+
.polymorphicTypeValidator(createPolymorphicTypeValidator());
6161
}
6262

6363
/**
@@ -66,34 +66,7 @@ public static JsonMapper.Builder createJsonMapperBuilder() {
6666
* @return an {@link JsonMapper.Builder} instance
6767
*/
6868
public static JsonMapper.Builder createJsonMapperBuilder(final JsonFactory factory) {
69-
// it is deliberate to have polymorphicTypeValidator that allows nothing
70-
// for security reasons
71-
// org.apache.drill.metastore.statistics.StatisticsHolder replaces this with
72-
// a polymorphicTypeValidator that allows only the types it needs
7369
return JsonMapper.builder(factory)
74-
.polymorphicTypeValidator(BasicPolymorphicTypeValidator.builder().build());
75-
}
76-
77-
/**
78-
* Creates a new instance of the Jackson {@link JsonMapper.Builder} that has a
79-
* <code>PolymorphicTypeValidator</code> applied that allows a curated set of classes
80-
* that can be loaded.
81-
* @return an {@link JsonMapper.Builder} instance
82-
*/
83-
public static JsonMapper.Builder createJsonMapperBuilderWithPolymorphicTypeValidator() {
84-
return createJsonMapperBuilder()
85-
.polymorphicTypeValidator(createPolymorphicTypeValidator());
86-
}
87-
88-
/**
89-
* Creates a new instance of the Jackson {@link JsonMapper.Builder} that has a
90-
* <code>PolymorphicTypeValidator</code> applied that allows a curated set of classes
91-
* that can be loaded.
92-
* @param factory a {@link JsonFactory} instance
93-
* @return an {@link JsonMapper.Builder} instance
94-
*/
95-
public static JsonMapper.Builder createJsonMapperBuilderWithPolymorphicTypeValidator(JsonFactory factory) {
96-
return createJsonMapperBuilder(factory)
9770
.polymorphicTypeValidator(createPolymorphicTypeValidator());
9871
}
9972

exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStatsTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public static ObjectMapper getMapper() {
470470
.addSerializer(TypeProtos.MajorType.class, new MajorTypeSerDe.Se())
471471
.addDeserializer(TypeProtos.MajorType.class, new MajorTypeSerDe.De())
472472
.addDeserializer(SchemaPath.class, new SchemaPath.De());
473-
ObjectMapper mapper = JacksonUtils.createJsonMapperBuilderWithPolymorphicTypeValidator()
473+
ObjectMapper mapper = JacksonUtils.createJsonMapperBuilder()
474474
.addModule(deModule)
475475
.build();
476476
mapper.registerSubtypes(new NamedType(NumericEquiDepthHistogram.class, "numeric-equi-depth"));

exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillValuesRelBase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@
5151
*/
5252
public abstract class DrillValuesRelBase extends Values implements DrillRelNode {
5353

54-
private static final ObjectMapper MAPPER =
55-
JacksonUtils.createJsonMapperBuilderWithPolymorphicTypeValidator().build();
54+
private static final ObjectMapper MAPPER = JacksonUtils.createObjectMapper();
5655

5756
protected final String content;
5857

exec/java-exec/src/main/java/org/apache/drill/exec/store/DrillbitPluginRegistryContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public DrillbitPluginRegistryContext(DrillbitContext drillbitContext) {
4545
// to handle HOCON format in the override file
4646
LogicalPlanPersistence persistence = new LogicalPlanPersistence(drillbitContext.getConfig(),
4747
drillbitContext.getClasspathScan(),
48-
JacksonUtils.createJsonMapperBuilderWithPolymorphicTypeValidator(new HoconFactory()).build());
48+
JacksonUtils.createJsonMapperBuilder(new HoconFactory()).build());
4949
hoconMapper = persistence.getMapper();
5050
}
5151

logical/src/main/java/org/apache/drill/common/config/LogicalPlanPersistence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class LogicalPlanPersistence {
4646
private final ObjectMapper mapper;
4747

4848
public LogicalPlanPersistence(DrillConfig conf, ScanResult scanResult) {
49-
this(conf, scanResult, JacksonUtils.createJsonMapperBuilderWithPolymorphicTypeValidator().build());
49+
this(conf, scanResult, JacksonUtils.createObjectMapper());
5050
}
5151

5252
public LogicalPlanPersistence(DrillConfig conf, ScanResult scanResult, ObjectMapper mapper) {

metastore/metastore-api/src/main/java/org/apache/drill/metastore/statistics/ColumnStatistics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
public class ColumnStatistics<T> {
6969

7070
private static final ObjectMapper MAPPER =
71-
JacksonUtils.createJsonMapperBuilderWithPolymorphicTypeValidator()
71+
JacksonUtils.createJsonMapperBuilder()
7272
.addModule(new JodaModule())
7373
.build();
7474

metastore/metastore-api/src/main/java/org/apache/drill/metastore/statistics/StatisticsHolder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
4040
public class StatisticsHolder<T> {
4141

42-
private static final ObjectMapper OBJECT_MAPPER =
43-
JacksonUtils.createJsonMapperBuilderWithPolymorphicTypeValidator().build();
42+
private static final ObjectMapper OBJECT_MAPPER = JacksonUtils.createObjectMapper();
4443
private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writerFor(StatisticsHolder.class);
4544
private static final ObjectReader OBJECT_READER = OBJECT_MAPPER.readerFor(StatisticsHolder.class);
4645

0 commit comments

Comments
 (0)