From 16465609afc9b356cb7710bf154f884948d1fb67 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Fri, 1 Sep 2006 13:30:13 +0000 Subject: [PATCH] Sorting dependencies before comparison or hashCode calculation to side-step a bug that was fixed in maven 2.0.5 dealing with the sorting of dependencies as they are declared in the POM. Sorting will be restricted to temp variables in those methods to avoid changing behavior. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@439314 13f79535-47bb-0310-9956-ffa450edef68 --- .../record/StandardArtifactIndexRecord.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java index 625d43e5f..7eb6e77a7 100644 --- a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java +++ b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java @@ -1,5 +1,7 @@ package org.apache.maven.archiva.indexer.record; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; /* @@ -174,10 +176,25 @@ public boolean equals( Object obj ) { return false; } - if ( dependencies != null ? !dependencies.equals( that.dependencies ) : that.dependencies != null ) + + if ( dependencies != null && that.dependencies != null ) + { + List sorted = new ArrayList( dependencies ); + Collections.sort( sorted ); + + List sortedOther = new ArrayList( that.dependencies ); + Collections.sort( sortedOther ); + + if ( !sorted.equals( sortedOther ) ) + { + return false; + } + } + else if ( !( dependencies == null && that.dependencies == null ) ) { return false; } + if ( developers != null ? !developers.equals( that.developers ) : that.developers != null ) { return false; @@ -247,7 +264,15 @@ public int hashCode() result = 31 * result + ( type != null ? type.hashCode() : 0 ); result = 31 * result + ( files != null ? files.hashCode() : 0 ); result = 31 * result + ( developers != null ? developers.hashCode() : 0 ); - result = 31 * result + ( dependencies != null ? dependencies.hashCode() : 0 ); + + if ( dependencies != null ) + { + List sorted = new ArrayList( dependencies ); + Collections.sort( sorted ); + + result = 31 * result + sorted.hashCode(); + } + result = 31 * result + ( repository != null ? repository.hashCode() : 0 ); result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 ); result = 31 * result + ( pluginPrefix != null ? pluginPrefix.hashCode() : 0 );