This is an automated email from the ASF dual-hosted git repository.
hapylestat pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new ed7bc49 AMBARI-25517. Should not use '!=' to compare 'Long hostId' in
HostStateEntity, which could lead to unforeseen problems (#3201) (rickyma via
dgrinenko)
ed7bc49 is described below
commit ed7bc49b657f7f9cb7f420c4a5f242e3dbe1c092
Author: RickyMa <[email protected]>
AuthorDate: Tue Jun 30 23:57:47 2020 +0800
AMBARI-25517. Should not use '!=' to compare 'Long hostId' in
HostStateEntity, which could lead to unforeseen problems (#3201) (rickyma via
dgrinenko)
---
.../ambari/server/orm/entities/HostStateEntity.java | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
index bcfffa6..41dd848 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
@@ -20,6 +20,8 @@ package org.apache.ambari.server.orm.entities;
import static org.apache.commons.lang.StringUtils.defaultString;
+import java.util.Objects;
+
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -137,23 +139,16 @@ public class HostStateEntity {
HostStateEntity that = (HostStateEntity) o;
- if (hostId != null ? hostId != that.hostId : that.hostId != null) return
false;
- if (availableMem != null ? !availableMem.equals(that.availableMem) :
that.availableMem != null) return false;
- if (timeInState != null ? !timeInState.equals(that.timeInState) :
that.timeInState!= null) return false;
- if (agentVersion != null ? !agentVersion.equals(that.agentVersion) :
that.agentVersion != null) return false;
- if (currentState != null ? !currentState.equals(that.currentState) :
that.currentState != null) return false;
-
- return true;
+ return Objects.equals(hostId, that.hostId) &&
+ Objects.equals(availableMem, that.availableMem) &&
+ Objects.equals(timeInState, that.timeInState) &&
+ Objects.equals(agentVersion, that.agentVersion) &&
+ currentState == that.currentState;
}
@Override
public int hashCode() {
- int result = hostId != null ? hostId.intValue() : 0;
- result = 31 * result + (availableMem != null ? availableMem.intValue() :
0);
- result = 31 * result + (timeInState != null ? timeInState.intValue() : 0);
- result = 31 * result + (agentVersion != null ? agentVersion.hashCode() :
0);
- result = 31 * result + (currentState != null ? currentState.hashCode() :
0);
- return result;
+ return Objects.hash(hostId, availableMem, timeInState, agentVersion,
currentState);
}
public HostEntity getHostEntity() {