maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject maven git commit: Fix for urls being empty in the POM and causing an out of bounds exception
Date Fri, 30 Oct 2015 01:34:29 GMT
Repository: maven
Updated Branches:
  refs/heads/master 508d97ec8 -> f684761de


Fix for urls being empty in the POM and causing an out of bounds exception


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/f684761d
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/f684761d
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/f684761d

Branch: refs/heads/master
Commit: f684761dee739b4ec8a7e6db5a0a6a0b809e66c9
Parents: 508d97e
Author: Jason van Zyl <jason@tesla.io>
Authored: Thu Oct 29 18:33:59 2015 -0700
Committer: Jason van Zyl <jason@tesla.io>
Committed: Thu Oct 29 18:33:59 2015 -0700

----------------------------------------------------------------------
 .../DefaultInheritanceAssembler.java            |  2 +-
 .../DefaultInheritanceAssemblerTest.java        |  8 +++-
 .../resources/poms/inheritance/empty-child.xml  | 31 ++++++++++++++++
 .../poms/inheritance/empty-expected.xml         | 39 ++++++++++++++++++++
 .../resources/poms/inheritance/empty-parent.xml | 37 +++++++++++++++++++
 5 files changed, 115 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/f684761d/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
index 5ffcf6d..fd1c07f 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
@@ -161,7 +161,7 @@ public class DefaultInheritanceAssembler
 
         private void concatPath( StringBuilder url, String path )
         {
-            if ( path.length() > 0 )
+            if ( url.length() > 0 && path.length() > 0 )
             {
                 boolean initialUrlEndsWithSlash = url.charAt( url.length() - 1 ) == '/';
                 boolean pathStartsWithSlash = path.charAt( 0 ) ==  '/';

http://git-wip-us.apache.org/repos/asf/maven/blob/f684761d/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
index ae45283..60f860f 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
@@ -137,6 +137,12 @@ public class DefaultInheritanceAssemblerTest
         }
     }
 
+    public void testWithEmptyUrl() 
+        throws Exception
+    {
+        	testInheritance( "empty", false );
+    }
+    
     public void testInheritance( String baseName )
         throws Exception
     {
@@ -177,5 +183,5 @@ public class DefaultInheritanceAssemblerTest
             XMLUnit.setIgnoreWhitespace( true );
             XMLAssert.assertXMLEqual( control, test );
         }
-    }
+    }    
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/f684761d/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml
new file mode 100644
index 0000000..88ccde4
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>inheritance</groupId>
+    <artifactId>empty</artifactId>
+    <version>1</version>
+  </parent>
+  <artifactId>child</artifactId>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/f684761d/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml
new file mode 100644
index 0000000..eac914a
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>inheritance</groupId>
+    <artifactId>empty</artifactId>
+    <version>1</version>
+  </parent>
+  <groupId>inheritance</groupId>  
+  <artifactId>child</artifactId>
+  <version>1</version>
+  <url></url>
+  <scm>
+    <connection>scm:my-scm:http://domain.org/base/child</connection>
+    <developerConnection>scm:my-scm:https://domain.org/base/child/</developerConnection>
+    <url></url>
+  </scm>  
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven/blob/f684761d/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml
----------------------------------------------------------------------
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml
new file mode 100644
index 0000000..8e94403
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>inheritance</groupId>
+  <artifactId>empty</artifactId>
+  <version>1</version>
+  <modules>
+    <module>child</module>
+  </modules>
+  <url></url>
+  <scm>
+    <connection>scm:my-scm:http://domain.org/base</connection>
+    <developerConnection>scm:my-scm:https://domain.org/base/</developerConnection>
+    <url></url>
+  </scm>
+</project>
\ No newline at end of file


Mime
View raw message