Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public abstract class ColumnDef implements Cloneable {
protected static final Interner INTERNER = Interners.newWeakInterner();
private static final DynamicEnum dynamicEnum = new DynamicEnum(Byte.MAX_VALUE);
private String name;
protected String name;
private final byte type;
private short pos;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import com.github.shyiko.mysql.binlog.event.deserialization.json.JsonBinary;
import com.zendesk.maxwell.producer.MaxwellOutputConfig;
import com.zendesk.maxwell.row.RawJSONString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class JsonColumnDef extends ColumnDef {
private static final Logger LOGGER = LoggerFactory.getLogger(JsonColumnDef.class);

private JsonColumnDef(String name, String type, short pos) {
super(name, type, pos);
}
Expand All @@ -25,7 +29,12 @@ public Object asJSON(Object value, MaxwellOutputConfig config) throws ColumnDefC
} else if ( value instanceof byte[] ){
try {
byte[] bytes = (byte[]) value;
jsonString = bytes.length > 0 ? JsonBinary.parseAsString(bytes) : "null";
if (bytes.length > 16384) {
LOGGER.warn("Skipping JSON over limit for field: " + name);
jsonString = "null";
} else {
jsonString = bytes.length > 0 ? JsonBinary.parseAsString(bytes) : "null";
}
return new RawJSONString(jsonString);
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down