This is an automated email from the ASF dual-hosted git repository. liujun pushed a commit to branch 2.7.0-release in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
commit b9c8bb831d5be17291ca076b47b14671c4ebdff5 Author: ken.lj <ken.lj...@gmail.com> AuthorDate: Mon Jan 7 21:09:26 2019 +0800 override equals of Config --- .../org/apache/dubbo/config/AbstractConfig.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java index 45a63f3..6b5fd0b 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractConfig.java @@ -620,4 +620,31 @@ public abstract class AbstractConfig implements Serializable { return true; } + @Override + public boolean equals(Object obj) { + if (obj == null || !(obj.getClass().getName().equals(this.getClass().getName()))) { + return false; + } + + Method[] methods = this.getClass().getMethods(); + for (Method method1 : methods) { + if (ClassHelper.isGetter(method1) && ClassHelper.isPrimitive(method1.getReturnType())) { + Parameter parameter = method1.getAnnotation(Parameter.class); + if (parameter != null && parameter.excluded()) { + continue; + } + try { + Method method2 = obj.getClass().getMethod(method1.getName(), method1.getParameterTypes()); + Object value1 = method1.invoke(this, new Object[]{}); + Object value2 = method2.invoke(obj, new Object[]{}); + if ((value1 != null && value2 != null) && !value1.equals(value2)) { + return false; + } + } catch (Exception e) { + return true; + } + } + } + return true; + } }