You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by mi...@apache.org on 2019/11/07 06:32:46 UTC
[phoenix] branch master updated: PHOENIX-5557 Prevent String
comparison using ==
This is an automated email from the ASF dual-hosted git repository.
mihir6692 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new ff00f67 PHOENIX-5557 Prevent String comparison using ==
ff00f67 is described below
commit ff00f67ffb2cf97adbd17cb67ff675f77a13930b
Author: Viraj Jasani <vi...@gmail.com>
AuthorDate: Thu Nov 7 12:00:37 2019 +0530
PHOENIX-5557 Prevent String comparison using ==
---
.../src/main/java/org/apache/phoenix/schema/SequenceKey.java | 10 ++++++++--
.../src/main/java/org/apache/phoenix/util/UpgradeUtil.java | 4 ++--
2 files changed, 10 insertions(+), 4 deletions(-)
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 @@ public class SequenceKey implements Comparable<SequenceKey> {
@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 @@ public class UpgradeUtil {
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 @@ public class UpgradeUtil {
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 {