Skip to content

Commit f5b2b52

Browse files
committed
Extract system property out to a constant
Signed-off-by: Mohit Godwani <[email protected]>
1 parent 9dac8d3 commit f5b2b52

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

libs/x-content/src/main/java/org/opensearch/common/xcontent/cbor/CborXContent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public class CborXContent implements XContent {
6363
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6464
);
6565

66+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
67+
6668
public static XContentBuilder contentBuilder() throws IOException {
6769
return XContentBuilder.builder(cborXContent);
6870
}
@@ -78,7 +80,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7880
cborFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7981
cborFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
8082
cborFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
81-
cborFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), Boolean.getBoolean("fast_double_writer.enabled"));
83+
cborFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
8284
cborXContent = new CborXContent();
8385
}
8486

libs/x-content/src/main/java/org/opensearch/common/xcontent/json/JsonXContent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public class JsonXContent implements XContent {
6262
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6363
);
6464

65+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
66+
6567
public static XContentBuilder contentBuilder() throws IOException {
6668
return XContentBuilder.builder(jsonXContent);
6769
}
@@ -80,7 +82,7 @@ public static XContentBuilder contentBuilder() throws IOException {
8082
jsonFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
8183
jsonFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
8284
jsonFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
83-
jsonFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), Boolean.getBoolean("fast_double_writer.enabled"));
85+
jsonFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
8486
jsonXContent = new JsonXContent();
8587
}
8688

libs/x-content/src/main/java/org/opensearch/common/xcontent/smile/SmileXContent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public class SmileXContent implements XContent {
6363
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6464
);
6565

66+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
67+
6668
public static XContentBuilder contentBuilder() throws IOException {
6769
return XContentBuilder.builder(smileXContent);
6870
}
@@ -80,7 +82,7 @@ public static XContentBuilder contentBuilder() throws IOException {
8082
smileFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
8183
smileFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
8284
smileFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
83-
smileFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), Boolean.getBoolean("fast_double_writer.enabled"));
85+
smileFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
8486
smileXContent = new SmileXContent();
8587
}
8688

libs/x-content/src/main/java/org/opensearch/common/xcontent/yaml/YamlXContent.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class YamlXContent implements XContent {
6161
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6262
);
6363

64+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
65+
6466
public static XContentBuilder contentBuilder() throws IOException {
6567
return XContentBuilder.builder(yamlXContent);
6668
}
@@ -73,7 +75,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7375
yamlFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7476
yamlFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
7577
yamlFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
76-
yamlFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), Boolean.getBoolean("fast_double_writer.enabled"));
78+
yamlFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
7779
yamlXContent = new YamlXContent();
7880
}
7981

0 commit comments

Comments
 (0)