Browse Source

Fix for error in inifinite loop checking in filtersets

PR: 23154


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275861 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
e2688b6318
3 changed files with 33 additions and 4 deletions
  1. +22
    -0
      src/etc/testcases/taskdefs/copy.xml
  2. +5
    -3
      src/main/org/apache/tools/ant/types/FilterSet.java
  3. +6
    -1
      src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java

+ 22
- 0
src/etc/testcases/taskdefs/copy.xml View File

@@ -10,6 +10,24 @@
<copy file="copy.xml" todir="copytest1dir" overwrite="true"/>
</target>

<target name="filtertest">
<!-- check fix for bugzilla 23154 -->
<delete quiet="yes" file="copy.filter.out"/>
<delete quiet="yes" file="copy.filter.inp"/>
<concat destfile="copy.filter.inp">
PRODUCT_VERSION=6.2.1.4
PRODUCT_BUILD=6.5 (BLD_65036)
PRODUCT_VERSION=6.2.1.4
PRODUCT_BUILD=6.5 (BLD_65036)
</concat>
<copy file="copy.filter.inp" tofile="copy.filter.out">
<filterset begintoken="6" endtoken="4">
<filter token=".2.1." value="2.6.4" />
</filterset>
</copy>
<concat><path path="copy.filter.out"/></concat>
</target>

<target name="test3">
<!-- create an empty file -->
<touch file="copytest3.tmp"/>
@@ -89,6 +107,8 @@
</copy>
</target>

<target name="cleanup">
<delete file="copytest1.tmp"/>
<delete file="copytest3.tmp"/>
@@ -99,6 +119,8 @@
<delete file="copy.filterset.tmp"/>
<delete file="copy.filterchain.tmp"/>
<delete dir="copytest1dir"/>
<delete quiet="yes" file="copy.filter.out"/>
<delete quiet="yes" file="copy.filter.inp"/>
</target>




+ 5
- 3
src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -357,6 +357,8 @@ public class FilterSet extends DataType implements Cloneable {
* @return The string with the tokens replaced.
*/
public String replaceTokens(String line) {
passedTokens = null; // reset for new line
String beginToken = getBeginToken();
String endToken = getEndToken();
int index = line.indexOf(beginToken);
@@ -415,7 +417,7 @@ public class FilterSet extends DataType implements Cloneable {
* This parses tokens which point to tokens.
* It also maintains a list of currently used tokens, so we cannot
* get into an infinite loop
* @param value the value / token to parse
* @param line the value / token to parse
* @param parent the parant token (= the token it was parsed from)
*/
private String replaceTokens(String line, String parent)
@@ -426,7 +428,7 @@ public class FilterSet extends DataType implements Cloneable {
if (passedTokens.contains(parent) && !duplicateToken) {
duplicateToken = true;
StringBuffer sb = new StringBuffer();
sb.append("Inifinite loop in tokens. Currently known tokens : ");
sb.append("Infinite loop in tokens. Currently known tokens : ");
sb.append(passedTokens);
sb.append("\nProblem token : " + getBeginToken() + parent
+ getEndToken());


+ 6
- 1
src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -126,6 +126,11 @@ public class CopyTest extends BuildFileTest {

}

public void testFilterTest() {
executeTarget("filtertest");
assertTrue(getOutput().indexOf("loop in tokens") == -1);
}
public void testFilterSet() throws IOException {
executeTarget("testFilterSet");
FileUtils fileUtils = FileUtils.newFileUtils();


Loading…
Cancel
Save