diff --git a/maven-repository/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java b/maven-repository/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java index 13c0066c9d..0af538ca53 100644 --- a/maven-repository/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java +++ b/maven-repository/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java @@ -42,7 +42,13 @@ public class DefaultMirrorBuilder ArtifactRepository mirror = new DefaultArtifactRepository( id, url, null ); - mirrors.put( mirrorOf, mirror ); + //System.out.println( mirror + " --> " + mirrorOf ); + + //first one must win so don't insert more. + if (!mirrors.containsKey( mirrorOf )) + { + mirrors.put( mirrorOf, mirror ); + } } /** @@ -67,6 +73,8 @@ public class DefaultMirrorBuilder if ( matchPattern( originalRepository, pattern ) ) { selectedMirror = mirrors.get( pattern ); + //stop on the first match. + break; } } } diff --git a/maven-repository/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/maven-repository/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java index 41b777283e..98468f6067 100644 --- a/maven-repository/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java +++ b/maven-repository/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java @@ -79,7 +79,7 @@ public class MirrorProcessorTest } - public void xtestMirrorStopOnFirstMatch() + public void testMirrorStopOnFirstMatch() { //exact matches win first mirrorBuilder.addMirror( "a2", "a,b", "http://a2" );