mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed #227 , loadBinlogChecksum NPE
This commit is contained in:
@@ -117,7 +117,7 @@ public class MysqlConnection implements ErosaConnection {
|
||||
LogDecoder decoder = new LogDecoder(LogEvent.UNKNOWN_EVENT, LogEvent.ENUM_END_EVENT);
|
||||
LogContext context = new LogContext();
|
||||
context.setLogPosition(new LogPosition(binlogfilename));
|
||||
context.setFormatDescription(new FormatDescriptionLogEvent(4,binlogChecksum));
|
||||
context.setFormatDescription(new FormatDescriptionLogEvent(4, binlogChecksum));
|
||||
while (fetcher.fetch()) {
|
||||
LogEvent event = null;
|
||||
event = decoder.decode(fetcher, context);
|
||||
@@ -266,11 +266,13 @@ public class MysqlConnection implements ErosaConnection {
|
||||
throw new IllegalStateException("unexpected binlog image query result:" + rs.getFieldValues());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主库checksum信息
|
||||
* https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html#option_mysqld_binlog-checksum
|
||||
* https://dev.mysql.com/doc/refman/5.6/en/replication-options
|
||||
* -binary-log.html#option_mysqld_binlog-checksum
|
||||
*/
|
||||
private void loadBinlogChecksum(){
|
||||
private void loadBinlogChecksum() {
|
||||
ResultSetPacket rs = null;
|
||||
try {
|
||||
rs = query("select @master_binlog_checksum");
|
||||
@@ -279,9 +281,9 @@ public class MysqlConnection implements ErosaConnection {
|
||||
}
|
||||
|
||||
List<String> columnValues = rs.getFieldValues();
|
||||
if(columnValues.get(0).toUpperCase().equals("CRC32")){
|
||||
if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0).toUpperCase().equals("CRC32")) {
|
||||
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
|
||||
}else{
|
||||
} else {
|
||||
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user