Browse Source

#52740: safer stream closing.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1294345 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 13 years ago
parent
commit
c28ec7da7a
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java

+ 9
- 6
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -1708,31 +1708,34 @@ public class Javadoc extends Task {
}

File tmpList = null;
BufferedWriter srcListWriter = null;

FileWriter wr = null;
try {
/**
* Write sourcefiles and package names to a temporary file
* if requested.
*/
BufferedWriter srcListWriter = null;
if (useExternalFile) {
tmpList = FILE_UTILS.createTempFile("javadoc", "", null, true, true);
toExecute.createArgument()
.setValue("@" + tmpList.getAbsolutePath());
srcListWriter = new BufferedWriter(
new FileWriter(tmpList.getAbsolutePath(),
true));
wr = new FileWriter(tmpList.getAbsolutePath(), true);
srcListWriter = new BufferedWriter(wr);
}

doSourceAndPackageNames(
toExecute, packagesToDoc, sourceFilesToDoc,
useExternalFile, tmpList, srcListWriter);

if (useExternalFile) {
srcListWriter.flush();
}
} catch (IOException e) {
tmpList.delete();
throw new BuildException("Error creating temporary file",
e, getLocation());
} finally {
FileUtils.close(srcListWriter);
FileUtils.close(wr);
}

if (packageList != null) {


Loading…
Cancel
Save