Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BA92B2009C6 for ; Sun, 1 May 2016 12:56:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B927F1609B2; Sun, 1 May 2016 12:56:06 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0CBFE1609A9 for ; Sun, 1 May 2016 12:56:05 +0200 (CEST) Received: (qmail 74378 invoked by uid 500); 1 May 2016 10:56:04 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 74113 invoked by uid 99); 1 May 2016 10:56:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 May 2016 10:56:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 96936E2EF4; Sun, 1 May 2016 10:56:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: olamy@apache.org To: commits@maven.apache.org Date: Sun, 01 May 2016 10:56:17 -0000 Message-Id: In-Reply-To: <690b1ea28c614089b60338c39fd1a1de@git.apache.org> References: <690b1ea28c614089b60338c39fd1a1de@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [15/50] [abbrv] maven-aether git commit: Bug 436290 - Trim whitespace from id/type list strings in DefaultMirrorSelector archived-at: Sun, 01 May 2016 10:56:06 -0000 Bug 436290 - Trim whitespace from id/type list strings in DefaultMirrorSelector Project: http://git-wip-us.apache.org/repos/asf/maven-aether/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-aether/commit/93310af9 Tree: http://git-wip-us.apache.org/repos/asf/maven-aether/tree/93310af9 Diff: http://git-wip-us.apache.org/repos/asf/maven-aether/diff/93310af9 Branch: refs/heads/master Commit: 93310af9fbeee588555148145ee3c5f560a3bb34 Parents: c9aeca7 Author: Benjamin Bentmann Authored: Sat May 31 17:20:09 2014 +0200 Committer: Benjamin Bentmann Committed: Sat May 31 17:20:09 2014 +0200 ---------------------------------------------------------------------- .../util/repository/DefaultMirrorSelector.java | 12 ++++++------ .../repository/DefaultMirrorSelectorTest.java | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-aether/blob/93310af9/aether-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java ---------------------------------------------------------------------- diff --git a/aether-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java b/aether-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java index b5ad2b2..a0f9a3b 100644 --- a/aether-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java +++ b/aether-util/src/main/java/org/eclipse/aether/util/repository/DefaultMirrorSelector.java @@ -40,12 +40,12 @@ public final class DefaultMirrorSelector * @param type The content type of the mirror, may be {@code null}. * @param repositoryManager A flag whether the mirror is a repository manager or a simple server. * @param mirrorOfIds The identifier(s) of remote repositories to mirror, may be {@code null}. Multiple identifiers - * can be separated by comma (',') and additionally the wildcards "*" and "external:*" can be used to - * match all (external) repositories, prefixing a repo id with an exclamation mark allows to express an - * exclusion. For example "external:*,!central". + * can be separated by comma (',') and surrounding whitespace is trimmed. Additionally the wildcards "*" + * and "external:*" can be used to match all (external) repositories, prefixing a repo id with an + * exclamation mark allows to express an exclusion. For example "external:*,!central". * @param mirrorOfTypes The content type(s) of remote repositories to mirror, may be {@code null} or empty to match - * any content type. Multiple types can be separated by comma (','), the wildcard "*" and the "!" - * negation syntax are also supported. For example "*,!p2". + * any content type. Multiple types can be separated by comma (',') and surrounding whitespace is + * trimmed. The wildcard "*" and the "!" negation syntax are also supported. For example "*,!p2". * @return This selector for chaining, never {@code null}. */ public DefaultMirrorSelector add( String id, String url, String type, boolean repositoryManager, @@ -137,7 +137,7 @@ public final class DefaultMirrorSelector List tokens = null; if ( list != null ) { - tokens = Arrays.asList( list.split( "," ) ); + tokens = Arrays.asList( list.trim().split( "\\s*,\\s*" ) ); } return tokens; } http://git-wip-us.apache.org/repos/asf/maven-aether/blob/93310af9/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultMirrorSelectorTest.java ---------------------------------------------------------------------- diff --git a/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultMirrorSelectorTest.java b/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultMirrorSelectorTest.java index b73c812..fd5aea4 100644 --- a/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultMirrorSelectorTest.java +++ b/aether-util/src/test/java/org/eclipse/aether/util/repository/DefaultMirrorSelectorTest.java @@ -81,6 +81,16 @@ public class DefaultMirrorSelectorTest } @Test + public void testMatchesType_Trimming() + { + assertEquals( true, matchesType( "any", " " ) ); + assertEquals( true, matchesType( "default", " default " ) ); + assertEquals( true, matchesType( "default", "foo, default ,bar" ) ); + assertEquals( true, matchesType( "default", " default ,bar" ) ); + assertEquals( true, matchesType( "default", "foo, default " ) ); + } + + @Test public void testMatchesPattern() { assertEquals( false, matchesPattern( newRepo( "id", "type", "url" ), null ) ); @@ -103,6 +113,16 @@ public class DefaultMirrorSelectorTest } @Test + public void testMatchesPattern_Trimming() + { + assertEquals( false, matchesPattern( newRepo( "central", "type", "url" ), " " ) ); + assertEquals( true, matchesPattern( newRepo( "central", "type", "url" ), " central " ) ); + assertEquals( true, matchesPattern( newRepo( "central", "type", "url" ), "foo, central ,bar" ) ); + assertEquals( true, matchesPattern( newRepo( "central", "type", "url" ), " central ,bar" ) ); + assertEquals( true, matchesPattern( newRepo( "central", "type", "url" ), "foo, central " ) ); + } + + @Test public void testGetMirror_FirstMatchWins() { DefaultMirrorSelector selector = new DefaultMirrorSelector();