Skip to content

Commit

Permalink
try harder to close streams. RAT-94
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/rat/main/trunk@1156170 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bodewig committed Aug 10, 2011
1 parent 18498fb commit aa767af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.txt
Expand Up @@ -10,6 +10,8 @@ RAT 0.8
* RAT-87 Tests could leave temporary files around.
* RAT-92 When adding licenses RAT used \n instead of the platform
dependent line--end character(s)
* RAT-94 Streams were not always closed immediately when adding
licenses.
* Improvement:
* RAT-79 Support automatic addition of license headers to Velocity
templates
Expand Down
Expand Up @@ -171,7 +171,8 @@ public void append(File document) throws IOException {

File newDocument = new File(document.getAbsolutePath() + ".new");
FileWriter writer = new FileWriter(newDocument);
if (!attachLicense(new FileWriter(newDocument), document,
try {
if (!attachLicense(writer, document,
expectsHashPling, expectsAtEcho, expectsPackage,
expectsXMLDecl, expectsPhpPI)) {
// Java File without package, XML file without decl or PHP
Expand All @@ -180,16 +181,17 @@ public void append(File document) throws IOException {
// an XML decl first - don't know how to handle PHP
if (expectsPackage || expectsXMLDecl) {
writer = new FileWriter(newDocument);
try {
if (expectsXMLDecl) {
writer.write("<?xml version='1.0'?>");
writer.write(LINE_SEP);
}
attachLicense(writer, document,
false, false, false, false, false);
} finally {
writer.close();
}
}
}
} finally {
if (writer != null) {
writer.close();
}
}

Expand Down

0 comments on commit aa767af

Please sign in to comment.