Claudenw commented on code in PR #223: URL: https://github.com/apache/creadur-rat/pull/223#discussion_r1531588952
########## apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java: ########## @@ -239,27 +241,28 @@ public void append(File document) throws IOException { // for Java just place the license at the front, for XML add // an XML decl first - don't know how to handle PHP if (expectsPackage || expectsXMLDecl) { - writer = new FileWriter(newDocument); - if (expectsXMLDecl) { - writer.write("<?xml version='1.0'?>"); - writer.write(LINE_SEP); + try (FileWriter writer2 = new FileWriter(newDocument)) { + if (expectsXMLDecl) { + writer2.write("<?xml version='1.0'?>"); + writer2.write(LINE_SEP); + } + attachLicense(writer2, document, + false, false, false, false, false, false); } - attachLicense(writer, document, - false, false, false, false, false, false); } } - } finally { - IOUtils.closeQuietly(writer); - } + } if (isForced) { - boolean deleted = document.delete(); - if (!deleted) { - log.error("Could not delete original file to prepare renaming."); - } - boolean renamed = newDocument.renameTo(document.getAbsoluteFile()); - if (!renamed) { - log.error("Failed to rename new file, original file remains unchanged."); + Path docPath = document.toPath(); Review Comment: good catch -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@creadur.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org