Merge pull request #92 from rhauch/dbz-107
DBZ-107 MySQL Connector should tolerate newlines in GTID sets read during snapshot
This commit is contained in:
commit
40318f87a3
@ -262,7 +262,7 @@ public void setGtid(String gtid) {
|
|||||||
*/
|
*/
|
||||||
public void setGtidSet(String gtidSet) {
|
public void setGtidSet(String gtidSet) {
|
||||||
if (gtidSet != null && !gtidSet.trim().isEmpty()) {
|
if (gtidSet != null && !gtidSet.trim().isEmpty()) {
|
||||||
this.gtidSet = gtidSet;
|
this.gtidSet = gtidSet.replaceAll("\n", ""); // remove all of the newline chars if they exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
import static org.fest.assertions.Assertions.assertThat;
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
import io.confluent.connect.avro.AvroData;
|
import io.confluent.connect.avro.AvroData;
|
||||||
|
import io.debezium.doc.FixFor;
|
||||||
import io.debezium.document.Document;
|
import io.debezium.document.Document;
|
||||||
|
|
||||||
public class SourceInfoTest {
|
public class SourceInfoTest {
|
||||||
@ -400,6 +401,33 @@ public void shouldOrderPositionWithGtidAsAfterPositionWithoutGtid() {
|
|||||||
assertPositionWithGtids("IdA:1-5").isAfter(positionWithoutGtids("filename.01", 0, 0));
|
assertPositionWithGtids("IdA:1-5").isAfter(positionWithoutGtids("filename.01", 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FixFor("DBZ-107")
|
||||||
|
@Test
|
||||||
|
public void shouldRemoveNewlinesFromGtidSet() {
|
||||||
|
String gtidExecuted = "036d85a9-64e5-11e6-9b48-42010af0000c:1-2,\n" +
|
||||||
|
"7145bf69-d1ca-11e5-a588-0242ac110004:1-3149,\n" +
|
||||||
|
"7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-39";
|
||||||
|
String gtidCleaned = "036d85a9-64e5-11e6-9b48-42010af0000c:1-2," +
|
||||||
|
"7145bf69-d1ca-11e5-a588-0242ac110004:1-3149," +
|
||||||
|
"7c1de3f2-3fd2-11e6-9cdc-42010af000bc:1-39";
|
||||||
|
source.setGtidSet(gtidExecuted);
|
||||||
|
assertThat(source.gtidSet()).isEqualTo(gtidCleaned);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FixFor("DBZ-107")
|
||||||
|
@Test
|
||||||
|
public void shouldNotSetBlankGtidSet() {
|
||||||
|
source.setGtidSet("");
|
||||||
|
assertThat(source.gtidSet()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FixFor("DBZ-107")
|
||||||
|
@Test
|
||||||
|
public void shouldNotSetNullGtidSet() {
|
||||||
|
source.setGtidSet(null);
|
||||||
|
assertThat(source.gtidSet()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
protected Document positionWithGtids(String gtids) {
|
protected Document positionWithGtids(String gtids) {
|
||||||
return positionWithGtids(gtids, false);
|
return positionWithGtids(gtids, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user