MNG-5638: Whitespaces matter in <mirrorOf> configuration can cause the incorrect repo to be selected

This commit is contained in:
Jason van Zyl 2014-06-11 22:26:18 -04:00
parent 425c663584
commit fddade227d
2 changed files with 17 additions and 0 deletions

View File

@ -89,6 +89,7 @@ public class DefaultMirrorSelector
String[] repos = pattern.split( "," );
for ( String repo : repos )
{
repo = repo.trim();
// see if this is a negative match
if ( repo.length() > 1 && repo.startsWith( "!" ) )
{

View File

@ -0,0 +1,16 @@
package org.apache.maven.repository;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.codehaus.plexus.PlexusTestCase;
public class DefaultMirrorSelectorTest extends PlexusTestCase {
public void testMirrorWithMirroOfPatternContainingANegationIsNotSelected() {
ArtifactRepository repository = new DefaultArtifactRepository("snapshots.repo", "http://whatever", null);
String pattern = "external:*, !snapshots.repo";
boolean matches = DefaultMirrorSelector.matchPattern(repository, pattern);
System.out.println(matches);
assertFalse(matches);
}
}