From ddbc1e07aafea4146437c89c1ac88023e3fa3460 Mon Sep 17 00:00:00 2001 From: Randall Hauch Date: Thu, 16 Mar 2017 13:55:24 -0500 Subject: [PATCH] DBZ-197 Corrected MySQL connector to handle invalid enum values MySQL represents an invalid enum literal in the binlog events as an empty string or an value of `0`. Now, when the connector comes across such a value in the binlog, it will instead use an empty string for the enum literal. --- .../debezium/connector/mysql/MySqlValueConverters.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/MySqlValueConverters.java b/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/MySqlValueConverters.java index 0232ba4cb..16103254e 100644 --- a/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/MySqlValueConverters.java +++ b/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/MySqlValueConverters.java @@ -306,8 +306,13 @@ protected Object convertEnumToString(List options, Column column, Field if (options != null) { // The binlog will contain an int with the 1-based index of the option in the enum value ... - int index = ((Integer) data).intValue() - 1; // 'options' is 0-based - if (index < options.size()) { + int value = ((Integer)data).intValue(); + if (value == 0) { + // an invalid value was specified, which corresponds to the empty string '' and an index of 0 + return ""; + } + int index = value - 1; // 'options' is 0-based + if (index < options.size() && index >= 0) { return options.get(index); } }