Browse Source

br 40949: Test of several resources on 1.3 showed that the compareTo method in the CompressedResource was defective.

HashMap on 1.4+ apparently checks using == before equals. When equals is used the compareTo on the CompressedResource would be called

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@473806 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 18 years ago
parent
commit
29c31d10c1
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      src/main/org/apache/tools/ant/types/resources/CompressedResource.java

+ 8
- 1
src/main/org/apache/tools/ant/types/resources/CompressedResource.java View File

@@ -159,7 +159,14 @@ public abstract class CompressedResource extends Resource {
* is less than, equal to, or greater than the specified Resource.
*/
public int compareTo(Object other) {
if (other == this) {
return 0;
}
if (other instanceof CompressedResource) {
return getResource().compareTo(((CompressedResource)other).getResource());
}
return getResource().compareTo(other);
}

/**
@@ -169,7 +176,7 @@ public abstract class CompressedResource extends Resource {
public int hashCode() {
return getResource().hashCode();
}
/**
* Get an InputStream for the Resource.
* @return an InputStream containing this Resource's content.


Loading…
Cancel
Save