PHOENIX-5557 Prevent String comparison using ==
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java
index 6f82630..f83fc04 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceKey.java
@@ -17,6 +17,8 @@
*/
package org.apache.phoenix.schema;
+import java.util.Objects;
+
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.util.ByteUtil;
@@ -56,9 +58,13 @@
@Override
public int compareTo(SequenceKey that) {
- int c = this.tenantId == that.getTenantId() ? 0 : this.tenantId == null ? -1 : that.getTenantId() == null ? 1 : this.tenantId.compareTo(that.getTenantId());
+ int c = Objects.equals(this.tenantId, that.getTenantId()) ? 0
+ : this.tenantId == null ? -1 : that.getTenantId() == null ? 1
+ : this.tenantId.compareTo(that.getTenantId());
if (c == 0) {
- c = this.schemaName == that.getSchemaName() ? 0 : this.schemaName == null ? -1 : that.getSchemaName() == null ? 1 : this.schemaName.compareTo(that.getSchemaName());
+ c = Objects.equals(this.schemaName, that.getSchemaName()) ? 0
+ : this.schemaName == null ? -1 : that.getSchemaName() == null ? 1
+ : this.schemaName.compareTo(that.getSchemaName());
if (c == 0) {
return sequenceName.compareTo(that.getSequenceName());
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index ca93bfb..e1a7608 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -1210,7 +1210,7 @@
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(HConstants.LATEST_TIMESTAMP));
while (rs.next()) {
String tenantId = rs.getString("TENANT_ID");
- if (prevTenantId != tenantId) {
+ if (!java.util.Objects.equals(prevTenantId, tenantId)) {
prevTenantId = tenantId;
props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
metaConn = new PhoenixConnection(oldMetaConnection, props);
@@ -2300,7 +2300,7 @@
for (TableInfo viewInfo : viewInfoList) {
tenantId = viewInfo.getTenantId()!=null ? Bytes.toString(viewInfo.getTenantId()) : null;
String viewName = SchemaUtil.getTableName(viewInfo.getSchemaName(), viewInfo.getTableName());
- if (prevTenantId != tenantId) {
+ if (!java.util.Objects.equals(prevTenantId, tenantId)) {
if (tenantId != null) {
props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
} else {