Browse Source

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
master
Peter Reilly 21 years ago
parent
commit
fa45d9628d
1 changed files with 8 additions and 15 deletions
  1. +8
    -15
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java

+ 8
- 15
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -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 <code>Object</code> value
* @return a <code>boolean</code> 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);
}
}



Loading…
Cancel
Save