summaryrefslogtreecommitdiffstats
path: root/feature-server-pool
diff options
context:
space:
mode:
authorTaka Cho <takamune.cho@att.com>2020-06-17 16:41:57 -0400
committerTaka Cho <takamune.cho@att.com>2020-06-18 09:31:58 -0400
commit21577893cd846442cf8832fdd0ff3d7d7db3e23b (patch)
tree17d2a97014aee72d1b3be40204bf76b7ed70933c /feature-server-pool
parent1fdba85a145be36060262d4575995a7752d7a396 (diff)
equals and hashCode should be overridden in pairs
hashCode should be overridden in pairs. followed by Effective Java: You must override hashCode() in every class that overrides equals(). Failure to do so will result in a violation of the general contract for Object.hashCode(), which will prevent your class from functioning properly in conjunction with all hash-based collections, including HashMap, HashSet, and Hashtable. Issue-ID: POLICY-2616 Change-Id: I2b29722daab5c520547397aae68d8ebaa71b2c4b Signed-off-by: Taka Cho <takamune.cho@att.com>
Diffstat (limited to 'feature-server-pool')
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java20
1 files changed, 2 insertions, 18 deletions
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
index dc4c0a79..b2e0fb29 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
@@ -59,6 +59,7 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.onap.policy.drools.core.DroolsRunnable;
import org.onap.policy.drools.core.PolicyContainer;
@@ -832,6 +833,7 @@ public class TargetLock implements Lock, Serializable {
* This class usually has a one-to-one correspondence with a 'TargetLock'
* instance, unless the 'TargetLock' has been abandoned.
*/
+ @EqualsAndHashCode
private static class Identity implements Serializable {
// this is the key associated with the lock
String key;
@@ -944,24 +946,6 @@ public class TargetLock implements Lock, Serializable {
}
return true;
}
-
- /***************************/
- /* 'Object' class override */
- /***************************/
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object other) {
- if (other instanceof Identity) {
- Identity identity = (Identity)other;
- return uuid.equals(identity.uuid)
- && key.equals(identity.key)
- && ownerKey.equals(identity.ownerKey);
- }
- return false;
- }
}
/* ============================================================ */