From fa45d9628d6fb4a8feb330027db88c5ce903cb56 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Mon, 17 May 2004 13:30:17 +0000 Subject: [PATCH] Fix use of hashcode in MacroDef Logger code uses the macrodef as a key in a map before it is fully configured so the hashcode had changed while the object was in the map PR: 28993 Obtained from: Jesse Glick git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276462 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/MacroDef.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java index 1b8dd49db..a25f3c923 100644 --- a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java +++ b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java @@ -596,13 +596,17 @@ public class MacroDef extends AntlibDefinition { } /** - * equality method for macrodef, ignores project and + * similar equality method for macrodef, ignores project and * runtime info. * * @param obj an Object value * @return a boolean value */ - public boolean equals(Object obj) { + public boolean similar(Object obj) { + if (obj == this) { + return true; + } + if (obj == null) { return false; } @@ -649,17 +653,6 @@ public class MacroDef extends AntlibDefinition { return true; } - /** - * @return a hash code value for this object. - */ - public int hashCode() { - return objectHashCode(name) - + objectHashCode(getURI()) - + objectHashCode(nestedSequential) - + objectHashCode(attributes) - + objectHashCode(elements); - } - /** * extends AntTypeDefinition, on create * of the object, the template macro definition @@ -704,7 +697,7 @@ public class MacroDef extends AntlibDefinition { return false; } MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other; - return macroDef.equals(otherDef.macroDef); + return macroDef.similar(otherDef.macroDef); } /** @@ -720,7 +713,7 @@ public class MacroDef extends AntlibDefinition { return false; } MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other; - return macroDef.equals(otherDef.macroDef); + return macroDef.similar(otherDef.macroDef); } }