From 9c7e0829060ef572fd6cb9209dc0b4e16d65c69d Mon Sep 17 00:00:00 2001 From: Brian E Fox Date: Fri, 9 Jan 2009 15:50:31 +0000 Subject: [PATCH] MNG-3974 - stop on first mirror pattern match (fix to handle repeated entires) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@733071 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/artifact/manager/DefaultWagonManager.java | 6 +++++- .../maven/artifact/manager/DefaultWagonManagerTest.java | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java index 53be1c4103..b8f73d0e1e 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -1109,7 +1109,11 @@ public class DefaultWagonManager ArtifactRepository mirror = new DefaultArtifactRepository( id, url, null ); - mirrors.put( mirrorOf, mirror ); + //to preserve first wins, don't add repeated mirrors. + if (!mirrors.containsKey( mirrorOf )) + { + mirrors.put( mirrorOf, mirror ); + } } public void setOnline( boolean online ) diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java index 4e82d8ca6f..514ee61e54 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/manager/DefaultWagonManagerTest.java @@ -585,6 +585,8 @@ public class DefaultWagonManagerTest //exact matches win first wagonManager.addMirror( "a2", "a,b", "http://a2" ); wagonManager.addMirror( "a", "a", "http://a" ); + //make sure repeated entries are skipped + wagonManager.addMirror( "a", "a", "http://a3" ); wagonManager.addMirror( "b", "b", "http://b" ); wagonManager.addMirror( "c", "d,e", "http://de" );