From d8b2bb7b3c280052de8769570ae9d699c65c1d35 Mon Sep 17 00:00:00 2001 From: Brian E Fox Date: Fri, 27 Feb 2009 20:43:58 +0000 Subject: [PATCH] re-fixing MNG-3974 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@748688 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/repository/DefaultMirrorBuilder.java | 10 +++++++++- .../apache/maven/repository/MirrorProcessorTest.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) 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" );