Skip to content

Commit cd24ce0

Browse files
committed
fix a few more calls and comments
1 parent c0867a1 commit cd24ce0

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJsonUtils.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,8 @@
3535
@Internal
3636
public class RowJsonUtils {
3737

38-
//
39-
private static int defaultBufferLimit;
40-
41-
/**
42-
* Increase the default jackson-databind stream read constraint.
43-
*
44-
* <p>StreamReadConstraints was introduced in jackson 2.15 causing string > 20MB (5MB in 2.15.0)
45-
* parsing failure. This has caused regressions in its dependencies include Beam. Here we
46-
* overwrite the default buffer size limit to 100 MB, and exposes this interface for higher limit.
47-
* If needed, call this method during pipeline run time, e.g. in DoFn.setup.
48-
*/
4938
// The maximum string length for the JSON parser, set to 100 MB.
50-
private static final int MAX_STRING_LENGTH = 100 * 1024 * 1024;
39+
public static final int MAX_STRING_LENGTH = 100 * 1024 * 1024;
5140

5241
/**
5342
* Creates a thread-safe JsonFactory with custom stream read constraints.
@@ -59,7 +48,7 @@ public class RowJsonUtils {
5948
* factory to higher limits. If needed, call this method during pipeline run time, e.g. in
6049
* DoFn.setup. This avoids a data race caused by modifying the global default settings.
6150
*/
62-
private static JsonFactory createJsonFactory(int sizeLimit) {
51+
public static JsonFactory createJsonFactory(int sizeLimit) {
6352
sizeLimit = Math.max(sizeLimit, MAX_STRING_LENGTH);
6453
JsonFactory jsonFactory = new JsonFactory();
6554
try {

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowJsonCoder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.beam.sdk.coders.AtomicCoder;
2929
import org.apache.beam.sdk.coders.Coder;
3030
import org.apache.beam.sdk.coders.StringUtf8Coder;
31+
import org.apache.beam.sdk.util.RowJson;
3132
import org.apache.beam.sdk.util.RowJsonUtils;
3233
import org.apache.beam.sdk.values.TypeDescriptor;
3334

@@ -75,10 +76,8 @@ public long getEncodedElementByteSize(TableRow value) throws Exception {
7576
private static final TypeDescriptor<TableRow> TYPE_DESCRIPTOR;
7677

7778
static {
78-
RowJsonUtils.increaseDefaultStreamReadConstraints(100 * 1024 * 1024);
79-
8079
MAPPER =
81-
new ObjectMapper()
80+
new ObjectMapper(RowJsonUtils.createJsonFactory(RowJsonUtils.MAX_STRING_LENGTH))
8281
.registerModule(new JavaTimeModule())
8382
.registerModule(new JodaModule())
8483
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)

0 commit comments

Comments
 (0)