From 29c31d10c11473e0a2711bc324f320610823426b Mon Sep 17 00:00:00 2001 From: Jacobus Martinus Kruithof Date: Sat, 11 Nov 2006 22:05:54 +0000 Subject: [PATCH] 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 --- .../tools/ant/types/resources/CompressedResource.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/types/resources/CompressedResource.java b/src/main/org/apache/tools/ant/types/resources/CompressedResource.java index ece5169ea..b5eb95758 100644 --- a/src/main/org/apache/tools/ant/types/resources/CompressedResource.java +++ b/src/main/org/apache/tools/ant/types/resources/CompressedResource.java @@ -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.