You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:05:51 UTC
[GitHub] [ambari] virajjasani commented on a change in pull request #3199: AMBARI-25517. Should not use '!=' to compare 'Long hostId' in HostStateEntity, which could lead to unforeseen problems
virajjasani commented on a change in pull request #3199:
URL: https://github.com/apache/ambari/pull/3199#discussion_r436648420
##########
File path: ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
##########
@@ -137,7 +137,7 @@ public boolean equals(Object o) {
HostStateEntity that = (HostStateEntity) o;
- if (hostId != null ? hostId != that.hostId : that.hostId != null) return false;
+ if (hostId != null ? !hostId.equals(that.hostId) : that.hostId != null) return false;
Review comment:
You might prefer using Objects.equals() here
##########
File path: ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
##########
@@ -137,7 +139,7 @@ public boolean equals(Object o) {
HostStateEntity that = (HostStateEntity) o;
- if (hostId != null ? hostId != that.hostId : that.hostId != null) return false;
+ if (hostId != null ? !Objects.equals(hostId, that.hostId) : that.hostId != null) return false;
Review comment:
This can be simplified to:
```
if (!Objects.equals(hostId, that.hostId)){
retur false;
}
```
##########
File path: ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
##########
@@ -137,7 +139,7 @@ public boolean equals(Object o) {
HostStateEntity that = (HostStateEntity) o;
- if (hostId != null ? hostId != that.hostId : that.hostId != null) return false;
+ if (hostId != null ? !Objects.equals(hostId, that.hostId) : that.hostId != null) return false;
Review comment:
Yes, that would be great
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org