Browse Source

Fix NPE in <concat>.

PR: 14310


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273518 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
abd749ac59
4 changed files with 21 additions and 4 deletions
  1. +3
    -0
      WHATSNEW
  2. +6
    -0
      src/etc/testcases/taskdefs/concat.xml
  3. +7
    -4
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  4. +5
    -0
      src/testcases/org/apache/tools/ant/taskdefs/ConcatTest.java

+ 3
- 0
WHATSNEW View File

@@ -42,6 +42,9 @@ Fixed bugs:
* <replace> would count some internal character replacements when
reporting the number of replaced tokens.

* <concat> would cause an exception if a <filelist> pointed to files
that do not exist.

Other changes:
--------------



+ 6
- 0
src/etc/testcases/taskdefs/concat.xml View File

@@ -31,4 +31,10 @@
<concat>Hello, ${world}!</concat>
</target>

<target name="test6">
<concat destfile="TESTDEST" append="true">
<filelist dir="${basedir}" files="thisfiledoesnotexist"/>
</concat>
</target>

</project>

+ 7
- 4
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -298,9 +298,8 @@ public class Concat extends Task {
private void catFiles(File base, String[] files) {

// First, create a list of absolute paths for the input files.
final int len = files.length;
String[] input = new String[len];
for (int i = 0; i < len; i++) {
Vector inputFileNames = new Vector();
for (int i = 0; i < files.length; i++) {

File current = new File(base, files[i]);

@@ -314,9 +313,13 @@ public class Concat extends Task {
continue;
}

input[i] = current.getAbsolutePath();
inputFileNames.addElement(current.getAbsolutePath());
}

final int len = inputFileNames.size();
String[] input = new String[len];
inputFileNames.copyInto(input);

// Next, perform the concatenation.
if (encoding == null) {
OutputStream os = null;


+ 5
- 0
src/testcases/org/apache/tools/ant/taskdefs/ConcatTest.java View File

@@ -161,4 +161,9 @@ public class ConcatTest
expectLog("test5", "Hello, World!");
}

public void test6() {
expectLogContaining("test6",
"src/etc/testcases/taskdefs/thisfiledoesnotexist does not exist.");
}

}

Loading…
Cancel
Save