mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Fix:Alibaba Coding Guidelines-Object的equals方法容易抛空指针异常,应使用常量或确定有值的对象来调用equals。 (#2919)
This commit is contained in:
@@ -282,7 +282,7 @@ public class PropertiesConfigurationFactory<T> implements FactoryBean<T>, Applic
|
|||||||
PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(this.target.getClass());
|
PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(this.target.getClass());
|
||||||
for (PropertyDescriptor descriptor : descriptors) {
|
for (PropertyDescriptor descriptor : descriptors) {
|
||||||
String name = descriptor.getName();
|
String name = descriptor.getName();
|
||||||
if (!name.equals("class")) {
|
if (!"class".equals(name)) {
|
||||||
RelaxedNames relaxedNames = RelaxedNames.forCamelCase(name);
|
RelaxedNames relaxedNames = RelaxedNames.forCamelCase(name);
|
||||||
if (prefixes == null) {
|
if (prefixes == null) {
|
||||||
for (String relaxedName : relaxedNames) {
|
for (String relaxedName : relaxedNames) {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class JdbcTypeUtil {
|
|||||||
|
|
||||||
public static Object typeConvert(String tableName ,String columnName, String value, int sqlType, String mysqlType) {
|
public static Object typeConvert(String tableName ,String columnName, String value, int sqlType, String mysqlType) {
|
||||||
if (value == null
|
if (value == null
|
||||||
|| (value.equals("") && !(isText(mysqlType) || sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR))) {
|
|| ("".equals(value) && !(isText(mysqlType) || sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,11 +95,11 @@ public class ESSyncService {
|
|||||||
long begin = System.currentTimeMillis();
|
long begin = System.currentTimeMillis();
|
||||||
|
|
||||||
String type = dml.getType();
|
String type = dml.getType();
|
||||||
if (type != null && type.equalsIgnoreCase("INSERT")) {
|
if (type != null && "INSERT".equalsIgnoreCase(type)) {
|
||||||
insert(config, dml);
|
insert(config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("UPDATE")) {
|
} else if (type != null && "UPDATE".equalsIgnoreCase(type)) {
|
||||||
update(config, dml);
|
update(config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("DELETE")) {
|
} else if (type != null && "DELETE".equalsIgnoreCase(type)) {
|
||||||
delete(config, dml);
|
delete(config, dml);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ public class MappingConfig implements AdapterConfig {
|
|||||||
columnItem.setRowKey(true);
|
columnItem.setRowKey(true);
|
||||||
rowKeyColumn = columnItem;
|
rowKeyColumn = columnItem;
|
||||||
} else {
|
} else {
|
||||||
if (field == null || field.equals("")) {
|
if (field == null || "".equals(field)) {
|
||||||
columnItem.setFamily(family);
|
columnItem.setFamily(family);
|
||||||
columnItem.setQualifier(columnField.getKey());
|
columnItem.setQualifier(columnField.getKey());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ public class HbaseSyncService {
|
|||||||
public void sync(MappingConfig config, Dml dml) {
|
public void sync(MappingConfig config, Dml dml) {
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
String type = dml.getType();
|
String type = dml.getType();
|
||||||
if (type != null && type.equalsIgnoreCase("INSERT")) {
|
if (type != null && "INSERT".equalsIgnoreCase(type)) {
|
||||||
insert(config, dml);
|
insert(config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("UPDATE")) {
|
} else if (type != null && "UPDATE".equalsIgnoreCase(type)) {
|
||||||
update(config, dml);
|
update(config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("DELETE")) {
|
} else if (type != null && "DELETE".equalsIgnoreCase(type)) {
|
||||||
delete(config, dml);
|
delete(config, dml);
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ public class KuduSyncService {
|
|||||||
public void sync(KuduMappingConfig config, Dml dml) {
|
public void sync(KuduMappingConfig config, Dml dml) {
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
String type = dml.getType();
|
String type = dml.getType();
|
||||||
if (type != null && type.equalsIgnoreCase("INSERT")) {
|
if (type != null && "INSERT".equalsIgnoreCase(type)) {
|
||||||
insert(config, dml);
|
insert(config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("UPDATE")) {
|
} else if (type != null && "UPDATE".equalsIgnoreCase(type)) {
|
||||||
upsert(config, dml);
|
upsert(config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("DELETE")) {
|
} else if (type != null && "DELETE".equalsIgnoreCase(type)) {
|
||||||
delete(config, dml);
|
delete(config, dml);
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|||||||
@@ -181,11 +181,11 @@ public class CommonRest {
|
|||||||
*/
|
*/
|
||||||
@PutMapping("/syncSwitch/{destination}/{status}")
|
@PutMapping("/syncSwitch/{destination}/{status}")
|
||||||
public Result etl(@PathVariable String destination, @PathVariable String status) {
|
public Result etl(@PathVariable String destination, @PathVariable String status) {
|
||||||
if (status.equals("on")) {
|
if ("on".equals(status)) {
|
||||||
syncSwitch.on(destination);
|
syncSwitch.on(destination);
|
||||||
logger.info("#Destination: {} sync on", destination);
|
logger.info("#Destination: {} sync on", destination);
|
||||||
return Result.createSuccess("实例: " + destination + " 开启同步成功");
|
return Result.createSuccess("实例: " + destination + " 开启同步成功");
|
||||||
} else if (status.equals("off")) {
|
} else if ("off".equals(status)) {
|
||||||
syncSwitch.off(destination);
|
syncSwitch.off(destination);
|
||||||
logger.info("#Destination: {} sync off", destination);
|
logger.info("#Destination: {} sync off", destination);
|
||||||
return Result.createSuccess("实例: " + destination + " 关闭同步成功");
|
return Result.createSuccess("实例: " + destination + " 关闭同步成功");
|
||||||
|
|||||||
@@ -208,13 +208,13 @@ public class RdbSyncService {
|
|||||||
if (config != null) {
|
if (config != null) {
|
||||||
try {
|
try {
|
||||||
String type = dml.getType();
|
String type = dml.getType();
|
||||||
if (type != null && type.equalsIgnoreCase("INSERT")) {
|
if (type != null && "INSERT".equalsIgnoreCase(type)) {
|
||||||
insert(batchExecutor, config, dml);
|
insert(batchExecutor, config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("UPDATE")) {
|
} else if (type != null && "UPDATE".equalsIgnoreCase(type)) {
|
||||||
update(batchExecutor, config, dml);
|
update(batchExecutor, config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("DELETE")) {
|
} else if (type != null && "DELETE".equalsIgnoreCase(type)) {
|
||||||
delete(batchExecutor, config, dml);
|
delete(batchExecutor, config, dml);
|
||||||
} else if (type != null && type.equalsIgnoreCase("TRUNCATE")) {
|
} else if (type != null && "TRUNCATE".equalsIgnoreCase(type)) {
|
||||||
truncate(batchExecutor, config);
|
truncate(batchExecutor, config);
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class SyncUtil {
|
|||||||
if (value instanceof Boolean) {
|
if (value instanceof Boolean) {
|
||||||
pstmt.setBoolean(i, (Boolean) value);
|
pstmt.setBoolean(i, (Boolean) value);
|
||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
boolean v = !value.equals("0");
|
boolean v = !"0".equals(value);
|
||||||
pstmt.setBoolean(i, v);
|
pstmt.setBoolean(i, v);
|
||||||
} else if (value instanceof Number) {
|
} else if (value instanceof Number) {
|
||||||
boolean v = ((Number) value).intValue() != 0;
|
boolean v = ((Number) value).intValue() != 0;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MQMessageUtils {
|
|||||||
int i = pkHashConfig.lastIndexOf(":");
|
int i = pkHashConfig.lastIndexOf(":");
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
String pkStr = pkHashConfig.substring(i + 1);
|
String pkStr = pkHashConfig.substring(i + 1);
|
||||||
if (pkStr.equalsIgnoreCase("$pk$")) {
|
if ("$pk$".equalsIgnoreCase(pkStr)) {
|
||||||
data.hashMode.autoPkHash = true;
|
data.hashMode.autoPkHash = true;
|
||||||
} else {
|
} else {
|
||||||
data.hashMode.pkNames = Lists.newArrayList(StringUtils.split(pkStr,
|
data.hashMode.pkNames = Lists.newArrayList(StringUtils.split(pkStr,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class JdbcTypeUtil {
|
|||||||
|
|
||||||
public static Object typeConvert(String tableName, String columnName, String value, int sqlType, String mysqlType) {
|
public static Object typeConvert(String tableName, String columnName, String value, int sqlType, String mysqlType) {
|
||||||
if (value == null
|
if (value == null
|
||||||
|| (value.equals("") && !(isText(mysqlType) || sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR))) {
|
|| ("".equals(value) && !(isText(mysqlType) || sqlType == Types.CHAR || sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ public class MysqlConnection implements ErosaConnection {
|
|||||||
rs = query("select @@global.binlog_checksum");
|
rs = query("select @@global.binlog_checksum");
|
||||||
List<String> columnValues = rs.getFieldValues();
|
List<String> columnValues = rs.getFieldValues();
|
||||||
if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0) != null
|
if (columnValues != null && columnValues.size() >= 1 && columnValues.get(0) != null
|
||||||
&& columnValues.get(0).toUpperCase().equals("CRC32")) {
|
&& "CRC32".equals(columnValues.get(0).toUpperCase())) {
|
||||||
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
|
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_CRC32;
|
||||||
} else {
|
} else {
|
||||||
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
|
binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class DescribeBackupPolicyRequest extends AbstractRequest<RdsBackupPolicy
|
|||||||
JSONObject jsonObj = JSON.parseObject(result);
|
JSONObject jsonObj = JSON.parseObject(result);
|
||||||
RdsBackupPolicy policy = new RdsBackupPolicy();
|
RdsBackupPolicy policy = new RdsBackupPolicy();
|
||||||
policy.setBackupRetentionPeriod(jsonObj.getString("BackupRetentionPeriod"));
|
policy.setBackupRetentionPeriod(jsonObj.getString("BackupRetentionPeriod"));
|
||||||
policy.setBackupLog(jsonObj.getString("BackupLog").equalsIgnoreCase("Enable"));
|
policy.setBackupLog("Enable".equalsIgnoreCase(jsonObj.getString("BackupLog")));
|
||||||
policy.setLogBackupRetentionPeriod(jsonObj.getIntValue("LogBackupRetentionPeriod"));
|
policy.setLogBackupRetentionPeriod(jsonObj.getIntValue("LogBackupRetentionPeriod"));
|
||||||
policy.setPreferredBackupPeriod(jsonObj.getString("PreferredBackupPeriod"));
|
policy.setPreferredBackupPeriod(jsonObj.getString("PreferredBackupPeriod"));
|
||||||
policy.setPreferredBackupTime(jsonObj.getString("PreferredBackupTime"));
|
policy.setPreferredBackupTime(jsonObj.getString("PreferredBackupTime"));
|
||||||
|
|||||||
Reference in New Issue
Block a user