You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2010/07/02 05:21:46 UTC
svn commit: r959838 -
/maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
Author: pgier
Date: Fri Jul 2 03:21:46 2010
New Revision: 959838
URL: http://svn.apache.org/viewvc?rev=959838&view=rev
Log:
Check for no match before trying to replace the string to prevent out of bounds exception.
Modified:
maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
Modified: maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java?rev=959838&r1=959837&r2=959838&view=diff
==============================================================================
--- maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java (original)
+++ maven/plugins/trunk/maven-antrun-plugin/src/main/java/org/apache/maven/plugin/antrun/AntRunMojo.java Fri Jul 2 03:21:46 2010
@@ -451,7 +451,8 @@ public class AntRunMojo
}
/**
- * Replace text in a string buffer
+ * Replace text in a StringBuffer. If the match text is not found, the StringBuffer
+ * is returned unchanged.
*
* @param text The string buffer containing the text
* @param match The string to match and remove
@@ -460,7 +461,10 @@ public class AntRunMojo
public void stringReplace( StringBuffer text, String match, String with )
{
int index = text.indexOf( match );
- text.replace( index, index + match.length(), with );
+ if ( index != -1 )
+ {
+ text.replace( index, index + match.length(), with );
+ }
}
public String checkTargetName( PlexusConfiguration antTargetConfig )