From 8838ae1417dd586126b9e29019b077516aa4f2d2 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 20 Apr 2022 10:00:39 +0800 Subject: [PATCH] Override hashCode and equals to avoid repeated item (#8207) --- .../remote/gprc/redo/data/RedoData.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/redo/data/RedoData.java b/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/redo/data/RedoData.java index a6c693742..e235a41b7 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/redo/data/RedoData.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/remote/gprc/redo/data/RedoData.java @@ -16,6 +16,8 @@ package com.alibaba.nacos.client.naming.remote.gprc.redo.data; +import java.util.Objects; + /** * Nacos naming redo data. * @@ -127,4 +129,22 @@ public abstract class RedoData { */ REMOVE; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RedoData redoData = (RedoData) o; + return registered == redoData.registered && unregistering == redoData.unregistering + && serviceName.equals(redoData.serviceName) && groupName.equals(redoData.groupName) && data.equals(redoData.data); + } + + @Override + public int hashCode() { + return Objects.hash(serviceName, groupName, registered, unregistering, data); + } }