From 4c85dfc33154be5933b4ecb302e395ce72c226a0 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Fri, 3 Mar 2006 15:27:25 +0000 Subject: [PATCH] Adding defensive code for one more place where cleanedPath length could cause a problem with string manipulation in appendPath(..). git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@382861 13f79535-47bb-0310-9956-ffa450edef68 --- .../inheritance/DefaultModelInheritanceAssembler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java index 218670e8cc..3f71af421e 100644 --- a/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java +++ b/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java @@ -482,6 +482,7 @@ public class DefaultModelInheritanceAssembler return repository; } + // TODO: This should eventually be migrated to DefaultPathTranslator. protected String appendPath( String parentPath, String childPath, String pathAdjustment, boolean appendPaths ) { List pathFragments = new ArrayList(); @@ -570,7 +571,12 @@ public class DefaultModelInheritanceAssembler if ( appendPaths && lastPathPart != null && !lastPathPart.endsWith( "/" ) ) { - cleanedPath.setLength( cleanedPath.length() - 1 ); + int cleanedPathLen = cleanedPath.length(); + + if ( cleanedPathLen > 0 ) + { + cleanedPath.setLength( cleanedPathLen - 1 ); + } } return cleanedPath.toString();