Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75EA09A7D for ; Tue, 13 Mar 2012 12:37:58 +0000 (UTC) Received: (qmail 52404 invoked by uid 500); 13 Mar 2012 12:37:58 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 52349 invoked by uid 500); 13 Mar 2012 12:37:58 -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 52342 invoked by uid 99); 13 Mar 2012 12:37:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 12:37:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2012 12:37:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 136C02388860; Tue, 13 Mar 2012 12:37:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1300099 - in /maven/plugins/trunk/maven-shade-plugin/src: it/empty-relocation-pattern/ it/empty-relocation-shaded-pattern/ main/java/org/apache/maven/plugins/shade/relocation/ test/java/org/apache/maven/plugins/shade/relocation/ Date: Tue, 13 Mar 2012 12:37:31 -0000 To: commits@maven.apache.org From: olamy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120313123732.136C02388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olamy Date: Tue Mar 13 12:37:31 2012 New Revision: 1300099 URL: http://svn.apache.org/viewvc?rev=1300099&view=rev Log: [MSHADE-94] NullPointerException on empty relocation pattern (default package) Submitted by Robert Burrell Donkin. Added: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/ maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml (with props) maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/ maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml (with props) maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java (with props) Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java Added: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml?rev=1300099&view=auto ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml (added) +++ maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml Tue Mar 13 12:37:31 2012 @@ -0,0 +1,66 @@ + + + + + 4.0.0 + + org.apache.maven.its.shade.eant + empty-relocation-pattern + 0.1 + jar + + MSHADE-94 + + Test that NullPointerException is not thrown when pattern parameter is unset. + + + + + + + org.apache.maven.plugins + maven-shade-plugin + @project.version@ + + + package + + shade + + + + + + + org.example + + + + + + + + + + Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-pattern/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml?rev=1300099&view=auto ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml (added) +++ maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml Tue Mar 13 12:37:31 2012 @@ -0,0 +1,65 @@ + + + + + 4.0.0 + + org.apache.maven.its.shade.eant + empty-relocation-shaded-pattern + 0.1 + jar + + MSHADE-94 + + Test that NullPointerException is not thrown when shadedPattern parameter is unset. + + + + + + org.apache.maven.plugins + maven-shade-plugin + @project.version@ + + + package + + shade + + + + + + org.example + + + + + + + + + + + Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-shade-plugin/src/it/empty-relocation-shaded-pattern/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java?rev=1300099&r1=1300098&r2=1300099&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java (original) +++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/relocation/SimpleRelocator.java Tue Mar 13 12:37:31 2012 @@ -19,6 +19,8 @@ package org.apache.maven.plugins.shade.r * under the License. */ +import org.codehaus.plexus.util.SelectorUtils; + import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashSet; @@ -26,8 +28,6 @@ import java.util.List; import java.util.Set; import java.util.regex.Pattern; -import org.codehaus.plexus.util.SelectorUtils; - /** * @author Jason van Zyl * @author Mauro Talevi @@ -47,18 +47,18 @@ public class SimpleRelocator private final Set includes; private final Set excludes; - + private final boolean rawString; public SimpleRelocator( String patt, String shadedPattern, List includes, List excludes ) { this( patt, shadedPattern, includes, excludes, false ); } - + public SimpleRelocator( String patt, String shadedPattern, List includes, List excludes, boolean rawString ) { this.rawString = rawString; - + if ( rawString ) { this.pathPattern = patt; @@ -69,8 +69,16 @@ public class SimpleRelocator } else { - this.pattern = patt.replace( '/', '.' ); - this.pathPattern = patt.replace( '.', '/' ); + if ( patt == null ) + { + this.pattern = ""; + this.pathPattern = ""; + } + else + { + this.pattern = patt.replace( '/', '.' ); + this.pathPattern = patt.replace( '.', '/' ); + } if ( shadedPattern != null ) { @@ -156,7 +164,7 @@ public class SimpleRelocator { return Pattern.compile( pathPattern ).matcher( path ).find(); } - + if ( path.endsWith( ".class" ) ) { path = path.substring( 0, path.length() - 6 ); Added: maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java?rev=1300099&view=auto ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java (added) +++ maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java Tue Mar 13 12:37:31 2012 @@ -0,0 +1,49 @@ +package org.apache.maven.plugins.shade.relocation; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Collections; + +import junit.framework.TestCase; + +public class SimpleRelocatorParameterTest extends TestCase { + + + protected void setUp() throws Exception { + super.setUp(); + } + + public void testThatNullPatternInConstructorShouldNotThrowNullPointerException() { + constructThenFailOnNullPointerException(null, ""); + } + + public void testThatNullShadedPatternInConstructorShouldNotThrowNullPointerException() { + constructThenFailOnNullPointerException("", null); + } + + private void constructThenFailOnNullPointerException( + String pattern, String shadedPattern) { + try { + new SimpleRelocator(pattern, shadedPattern, Collections.EMPTY_LIST, Collections.EMPTY_LIST); + } catch (NullPointerException e) { + fail("Constructor should not throw null pointer exceptions"); + } + } +} Propchange: maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorParameterTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java?rev=1300099&r1=1300098&r2=1300099&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java (original) +++ maven/plugins/trunk/maven-shade-plugin/src/test/java/org/apache/maven/plugins/shade/relocation/SimpleRelocatorTest.java Tue Mar 13 12:37:31 2012 @@ -1,12 +1,12 @@ package org.apache.maven.plugins.shade.relocation; -import java.util.Arrays; - import junit.framework.TestCase; +import java.util.Arrays; + /** * Test for {@link SimpleRelocator}. - * + * * @author Benjamin Bentmann * @version $Id$ */ @@ -28,9 +28,8 @@ public class SimpleRelocatorTest assertEquals( false, relocator.canRelocatePath( "org/Foo/Class" ) ); assertEquals( false, relocator.canRelocatePath( "org/Foo/Class.class" ) ); - relocator = - new SimpleRelocator( "org.foo", null, null, Arrays.asList( new String[] { "org.foo.Excluded", "org.foo.public.*", - "org.foo.Public*Stuff" } ) ); + relocator = new SimpleRelocator( "org.foo", null, null, Arrays.asList( + new String[]{ "org.foo.Excluded", "org.foo.public.*", "org.foo.Public*Stuff" } ) ); assertEquals( true, relocator.canRelocatePath( "org/foo/Class" ) ); assertEquals( true, relocator.canRelocatePath( "org/foo/Class.class" ) ); assertEquals( true, relocator.canRelocatePath( "org/foo/excluded" ) ); @@ -58,9 +57,8 @@ public class SimpleRelocatorTest assertEquals( false, relocator.canRelocateClass( "com.foo.bar.Class" ) ); assertEquals( false, relocator.canRelocateClass( "org.Foo.Class" ) ); - relocator = - new SimpleRelocator( "org.foo", null, null, Arrays.asList( new String[] { "org.foo.Excluded", "org.foo.public.*", - "org.foo.Public*Stuff" } ) ); + relocator = new SimpleRelocator( "org.foo", null, null, Arrays.asList( + new String[]{ "org.foo.Excluded", "org.foo.public.*", "org.foo.Public*Stuff" } ) ); assertEquals( true, relocator.canRelocateClass( "org.foo.Class" ) ); assertEquals( true, relocator.canRelocateClass( "org.foo.excluded" ) ); assertEquals( false, relocator.canRelocateClass( "org.foo.Excluded" ) ); @@ -71,7 +69,7 @@ public class SimpleRelocatorTest assertEquals( false, relocator.canRelocateClass( "org.foo.PublicStuff" ) ); assertEquals( false, relocator.canRelocateClass( "org.foo.PublicUtilStuff" ) ); } - + public void testCanRelocateRawString() { SimpleRelocator relocator;