From b82c8bca83d39b12c40887e920ee9266500713dc Mon Sep 17 00:00:00 2001 From: Tocker Date: Thu, 20 Aug 2020 21:17:44 +0800 Subject: [PATCH] =?UTF-8?q?Fix:Alibaba=20Coding=20Guidelines-Object?= =?UTF-8?q?=E7=9A=84equals=E6=96=B9=E6=B3=95=E5=AE=B9=E6=98=93=E6=8A=9B?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82=E5=B8=B8=EF=BC=8C=E5=BA=94?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=B8=B8=E9=87=8F=E6=88=96=E7=A1=AE=E5=AE=9A?= =?UTF-8?q?=E6=9C=89=E5=80=BC=E7=9A=84=E5=AF=B9=E8=B1=A1=E6=9D=A5=E8=B0=83?= =?UTF-8?q?=E7=94=A8equals=E3=80=82=20(#2919)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/bind/PropertiesConfigurationFactory.java | 2 +- .../otter/canal/client/adapter/support/JdbcTypeUtil.java | 2 +- .../client/adapter/es/core/service/ESSyncService.java | 6 +++--- .../canal/client/adapter/hbase/config/MappingConfig.java | 2 +- .../client/adapter/hbase/service/HbaseSyncService.java | 6 +++--- .../client/adapter/kudu/service/KuduSyncService.java | 6 +++--- .../otter/canal/adapter/launcher/rest/CommonRest.java | 4 ++-- .../canal/client/adapter/rdb/service/RdbSyncService.java | 8 ++++---- .../otter/canal/client/adapter/rdb/support/SyncUtil.java | 2 +- .../canal/connector/core/producer/MQMessageUtils.java | 2 +- .../otter/canal/connector/core/util/JdbcTypeUtil.java | 2 +- .../otter/canal/parse/inbound/mysql/MysqlConnection.java | 2 +- .../mysql/rds/request/DescribeBackupPolicyRequest.java | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/bind/PropertiesConfigurationFactory.java b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/bind/PropertiesConfigurationFactory.java index 76a97c0b..f44c9a5a 100644 --- a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/bind/PropertiesConfigurationFactory.java +++ b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/config/bind/PropertiesConfigurationFactory.java @@ -282,7 +282,7 @@ public class PropertiesConfigurationFactory implements FactoryBean, Applic PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(this.target.getClass()); for (PropertyDescriptor descriptor : descriptors) { String name = descriptor.getName(); - if (!name.equals("class")) { + if (!"class".equals(name)) { RelaxedNames relaxedNames = RelaxedNames.forCamelCase(name); if (prefixes == null) { for (String relaxedName : relaxedNames) { diff --git a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java index 4dd061c6..a9a27960 100644 --- a/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java +++ b/client-adapter/common/src/main/java/com/alibaba/otter/canal/client/adapter/support/JdbcTypeUtil.java @@ -78,7 +78,7 @@ public class JdbcTypeUtil { public static Object typeConvert(String tableName ,String columnName, String value, int sqlType, String mysqlType) { 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; } diff --git a/client-adapter/escore/src/main/java/com/alibaba/otter/canal/client/adapter/es/core/service/ESSyncService.java b/client-adapter/escore/src/main/java/com/alibaba/otter/canal/client/adapter/es/core/service/ESSyncService.java index 4ca23af2..7b4b86a3 100644 --- a/client-adapter/escore/src/main/java/com/alibaba/otter/canal/client/adapter/es/core/service/ESSyncService.java +++ b/client-adapter/escore/src/main/java/com/alibaba/otter/canal/client/adapter/es/core/service/ESSyncService.java @@ -95,11 +95,11 @@ public class ESSyncService { long begin = System.currentTimeMillis(); String type = dml.getType(); - if (type != null && type.equalsIgnoreCase("INSERT")) { + if (type != null && "INSERT".equalsIgnoreCase(type)) { insert(config, dml); - } else if (type != null && type.equalsIgnoreCase("UPDATE")) { + } else if (type != null && "UPDATE".equalsIgnoreCase(type)) { update(config, dml); - } else if (type != null && type.equalsIgnoreCase("DELETE")) { + } else if (type != null && "DELETE".equalsIgnoreCase(type)) { delete(config, dml); } else { return; diff --git a/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/config/MappingConfig.java b/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/config/MappingConfig.java index 21ac327c..4940a58c 100644 --- a/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/config/MappingConfig.java +++ b/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/config/MappingConfig.java @@ -312,7 +312,7 @@ public class MappingConfig implements AdapterConfig { columnItem.setRowKey(true); rowKeyColumn = columnItem; } else { - if (field == null || field.equals("")) { + if (field == null || "".equals(field)) { columnItem.setFamily(family); columnItem.setQualifier(columnField.getKey()); } else { diff --git a/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/service/HbaseSyncService.java b/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/service/HbaseSyncService.java index e0dc1279..b4464cab 100644 --- a/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/service/HbaseSyncService.java +++ b/client-adapter/hbase/src/main/java/com/alibaba/otter/canal/client/adapter/hbase/service/HbaseSyncService.java @@ -31,11 +31,11 @@ public class HbaseSyncService { public void sync(MappingConfig config, Dml dml) { if (config != null) { String type = dml.getType(); - if (type != null && type.equalsIgnoreCase("INSERT")) { + if (type != null && "INSERT".equalsIgnoreCase(type)) { insert(config, dml); - } else if (type != null && type.equalsIgnoreCase("UPDATE")) { + } else if (type != null && "UPDATE".equalsIgnoreCase(type)) { update(config, dml); - } else if (type != null && type.equalsIgnoreCase("DELETE")) { + } else if (type != null && "DELETE".equalsIgnoreCase(type)) { delete(config, dml); } if (logger.isDebugEnabled()) { diff --git a/client-adapter/kudu/src/main/java/com/alibaba/otter/canal/client/adapter/kudu/service/KuduSyncService.java b/client-adapter/kudu/src/main/java/com/alibaba/otter/canal/client/adapter/kudu/service/KuduSyncService.java index d388b410..4f5ca799 100644 --- a/client-adapter/kudu/src/main/java/com/alibaba/otter/canal/client/adapter/kudu/service/KuduSyncService.java +++ b/client-adapter/kudu/src/main/java/com/alibaba/otter/canal/client/adapter/kudu/service/KuduSyncService.java @@ -47,11 +47,11 @@ public class KuduSyncService { public void sync(KuduMappingConfig config, Dml dml) { if (config != null) { String type = dml.getType(); - if (type != null && type.equalsIgnoreCase("INSERT")) { + if (type != null && "INSERT".equalsIgnoreCase(type)) { insert(config, dml); - } else if (type != null && type.equalsIgnoreCase("UPDATE")) { + } else if (type != null && "UPDATE".equalsIgnoreCase(type)) { upsert(config, dml); - } else if (type != null && type.equalsIgnoreCase("DELETE")) { + } else if (type != null && "DELETE".equalsIgnoreCase(type)) { delete(config, dml); } if (logger.isDebugEnabled()) { diff --git a/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/rest/CommonRest.java b/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/rest/CommonRest.java index 32b39f47..a7aa1afb 100644 --- a/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/rest/CommonRest.java +++ b/client-adapter/launcher/src/main/java/com/alibaba/otter/canal/adapter/launcher/rest/CommonRest.java @@ -181,11 +181,11 @@ public class CommonRest { */ @PutMapping("/syncSwitch/{destination}/{status}") public Result etl(@PathVariable String destination, @PathVariable String status) { - if (status.equals("on")) { + if ("on".equals(status)) { syncSwitch.on(destination); logger.info("#Destination: {} sync on", destination); return Result.createSuccess("实例: " + destination + " 开启同步成功"); - } else if (status.equals("off")) { + } else if ("off".equals(status)) { syncSwitch.off(destination); logger.info("#Destination: {} sync off", destination); return Result.createSuccess("实例: " + destination + " 关闭同步成功"); diff --git a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/service/RdbSyncService.java b/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/service/RdbSyncService.java index 73392751..64015268 100644 --- a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/service/RdbSyncService.java +++ b/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/service/RdbSyncService.java @@ -208,13 +208,13 @@ public class RdbSyncService { if (config != null) { try { String type = dml.getType(); - if (type != null && type.equalsIgnoreCase("INSERT")) { + if (type != null && "INSERT".equalsIgnoreCase(type)) { insert(batchExecutor, config, dml); - } else if (type != null && type.equalsIgnoreCase("UPDATE")) { + } else if (type != null && "UPDATE".equalsIgnoreCase(type)) { update(batchExecutor, config, dml); - } else if (type != null && type.equalsIgnoreCase("DELETE")) { + } else if (type != null && "DELETE".equalsIgnoreCase(type)) { delete(batchExecutor, config, dml); - } else if (type != null && type.equalsIgnoreCase("TRUNCATE")) { + } else if (type != null && "TRUNCATE".equalsIgnoreCase(type)) { truncate(batchExecutor, config); } if (logger.isDebugEnabled()) { diff --git a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java b/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java index 25247642..88f1ec94 100644 --- a/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java +++ b/client-adapter/rdb/src/main/java/com/alibaba/otter/canal/client/adapter/rdb/support/SyncUtil.java @@ -71,7 +71,7 @@ public class SyncUtil { if (value instanceof Boolean) { pstmt.setBoolean(i, (Boolean) value); } else if (value instanceof String) { - boolean v = !value.equals("0"); + boolean v = !"0".equals(value); pstmt.setBoolean(i, v); } else if (value instanceof Number) { boolean v = ((Number) value).intValue() != 0; diff --git a/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/producer/MQMessageUtils.java b/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/producer/MQMessageUtils.java index ad2b4c87..e1678698 100644 --- a/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/producer/MQMessageUtils.java +++ b/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/producer/MQMessageUtils.java @@ -49,7 +49,7 @@ public class MQMessageUtils { int i = pkHashConfig.lastIndexOf(":"); if (i > 0) { String pkStr = pkHashConfig.substring(i + 1); - if (pkStr.equalsIgnoreCase("$pk$")) { + if ("$pk$".equalsIgnoreCase(pkStr)) { data.hashMode.autoPkHash = true; } else { data.hashMode.pkNames = Lists.newArrayList(StringUtils.split(pkStr, diff --git a/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/util/JdbcTypeUtil.java b/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/util/JdbcTypeUtil.java index 50053f49..ffca31a6 100644 --- a/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/util/JdbcTypeUtil.java +++ b/connector/core/src/main/java/com/alibaba/otter/canal/connector/core/util/JdbcTypeUtil.java @@ -78,7 +78,7 @@ public class JdbcTypeUtil { public static Object typeConvert(String tableName, String columnName, String value, int sqlType, String mysqlType) { 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; } diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java index ffe8eafd..785f2950 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/MysqlConnection.java @@ -522,7 +522,7 @@ public class MysqlConnection implements ErosaConnection { rs = query("select @@global.binlog_checksum"); List columnValues = rs.getFieldValues(); 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; } else { binlogChecksum = LogEvent.BINLOG_CHECKSUM_ALG_OFF; diff --git a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java index cf51961a..c5a9b501 100644 --- a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java +++ b/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/rds/request/DescribeBackupPolicyRequest.java @@ -31,7 +31,7 @@ public class DescribeBackupPolicyRequest extends AbstractRequest