DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22007>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22007

Copy task throws StringIndexOutOfBoundsException when a replacement token value 
is the empty string

           Summary: Copy task throws StringIndexOutOfBoundsException when a
                    replacement token value is the empty string
           Product: Ant
           Version: 1.5.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


A copy task that uses replacetokens to replace a key with an empty string 
throws a StringIndexOutOfBoundsException. For example:
    <copy tofile="${destfile}" file="${srcfile}">
      <filterchain>
        <replacetokens>
          <!-- replace @someKey@ with nothing -->
          <token key="someKey" value=""/>
        </replacetokens>
      </filterchain>
    </copy>

Workaround: Set the token value to a single space instead of the empty String:
          <!-- replace @someKey@ with a space " " -->
          <token key="someKey" value=" "/>

The bug is caused by this code in ReplaceTokens.java
    public final int read() throws IOException {
        // ...snip...
        // the call to String.charAt throws a StringIndexOutOfBoundsException

        if (replaceIndex != -1) { // line 159
            final int ch = replaceData.charAt(replaceIndex++);
            if (replaceIndex >= replaceData.length()) {
                replaceIndex = -1;
            }
            return ch;
        }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to