flink-cdc
flink-cdc copied to clipboard
[cdc-connector][mysql][hotfix] Fix NullPointerException when currentReader is null.
In current com.ververica.cdc.connectors.mysql.source.reader.MySqlSplitReader#pollSplitRecords, if currentReader == null(for example, there is no split), NullPointerException will be thrown here:
private MySqlRecords pollSplitRecords() throws InterruptedException {
Iterator<SourceRecords> dataIt;
if (currentReader == null) {
// (1) Reads binlog split firstly and then read snapshot split
if (binlogSplits.size() > 0) {
// the binlog split may come from:
// (a) the initial binlog split
// (b) added back binlog-split in newly added table process
MySqlSplit nextSplit = binlogSplits.poll();
currentSplitId = nextSplit.splitId();
currentReader = getBinlogSplitReader();
currentReader.submitSplit(nextSplit);
} else if (snapshotSplits.size() > 0) {
MySqlSplit nextSplit = snapshotSplits.poll();
currentSplitId = nextSplit.splitId();
currentReader = getSnapshotSplitReader();
currentReader.submitSplit(nextSplit);
} else {
LOG.info("No available split to read.");
}
dataIt = currentReader.pollSplitRecords();
}
@leonardBang , @ruanhang1993 , @Shawn-Hx , CC
@ruanhang1993 , CC
This pull request has been automatically marked as stale because it has not had recent activity for 60 days. It will be closed in 30 days if no further activity occurs.