Skip to content

Commit f00f4e0

Browse files
committed
skip JSON over 16kb
1 parent e4eddc9 commit f00f4e0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/com/zendesk/maxwell/schema/columndef/ColumnDef.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public abstract class ColumnDef implements Cloneable {
2323
protected static final Interner INTERNER = Interners.newWeakInterner();
2424
private static final DynamicEnum dynamicEnum = new DynamicEnum(Byte.MAX_VALUE);
25-
private String name;
25+
protected String name;
2626
private final byte type;
2727
private short pos;
2828

src/main/java/com/zendesk/maxwell/schema/columndef/JsonColumnDef.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import com.github.shyiko.mysql.binlog.event.deserialization.json.JsonBinary;
44
import com.zendesk.maxwell.producer.MaxwellOutputConfig;
55
import com.zendesk.maxwell.row.RawJSONString;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
68

79
import java.io.IOException;
810

911
public class JsonColumnDef extends ColumnDef {
12+
private static final Logger LOGGER = LoggerFactory.getLogger(JsonColumnDef.class);
13+
1014
private JsonColumnDef(String name, String type, short pos) {
1115
super(name, type, pos);
1216
}
@@ -25,7 +29,12 @@ public Object asJSON(Object value, MaxwellOutputConfig config) throws ColumnDefC
2529
} else if ( value instanceof byte[] ){
2630
try {
2731
byte[] bytes = (byte[]) value;
28-
jsonString = bytes.length > 0 ? JsonBinary.parseAsString(bytes) : "null";
32+
if (bytes.length > 16384) {
33+
LOGGER.warn("Skipping JSON over limit for field: " + name);
34+
jsonString = "null";
35+
} else {
36+
jsonString = bytes.length > 0 ? JsonBinary.parseAsString(bytes) : "null";
37+
}
2938
return new RawJSONString(jsonString);
3039
} catch (IOException e) {
3140
throw new RuntimeException(e);

0 commit comments

Comments
 (0)