Bug 18625 - <replacetokens>: token with empty value throws IndexOutOfBoundsException
Summary: <replacetokens>: token with empty value throws IndexOutOfBoundsException
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.5.2
Hardware: Other Linux
: P3 blocker (vote)
Target Milestone: 1.6
Assignee: Ant Notifications List
URL:
Keywords:
: 22007 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-04-02 19:41 UTC by Bob Cotton
Modified: 2004-11-16 19:05 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Cotton 2003-04-02 19:41:34 UTC
Having a value="" as a token value in the follwoing:

       <loadproperties srcFile="build.properties">
            <filterchain>
                <replacetokens begintoken="(" endtoken=")">
                    <token key="${env.LOGNAME}" value=""/>
                </replacetokens>
            </filterchain>
        </loadproperties>

Throws this exception:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:460)
        at org.apache.tools.ant.filters.ReplaceTokens.read(ReplaceTokens.java:160)
        at org.apache.tools.ant.filters.ReplaceTokens.read(ReplaceTokens.java:196)
        at
org.apache.tools.ant.filters.BaseFilterReader.read(BaseFilterReader.java:123)
        at java.io.Reader.read(Reader.java:100)
        at org.apache.tools.ant.util.FileUtils.readFully(FileUtils.java:793)
        at
org.apache.tools.ant.filters.util.ChainReaderHelper.readFully(ChainReaderHelper.java:238)
        at
org.apache.tools.ant.taskdefs.LoadProperties.execute(LoadProperties.java:139)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at org.apache.tools.ant.Target.execute(Target.java:309)
        at org.apache.tools.ant.Target.performTasks(Target.java:336)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:397)
        at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:143)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at org.apache.tools.ant.Target.execute(Target.java:309)
        at org.apache.tools.ant.Target.performTasks(Target.java:336)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
        at org.apache.tools.ant.Main.runBuild(Main.java:609)
        at org.apache.tools.ant.Main.start(Main.java:196)
        at org.apache.tools.ant.Main.main(Main.java:235)

any other non-zero length string will replace fine. But as you can see from the
loadproperties task, I need an empty string.
Comment 1 Stefan Bodewig 2003-04-09 15:40:07 UTC
fixed in nightly build 2003-04-10.
Comment 2 Antoine Levy-Lambert 2003-07-31 09:51:28 UTC
*** Bug 22007 has been marked as a duplicate of this bug. ***