DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7302>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7302 Files left open in FileUtils Summary: Files left open in FileUtils Product: Ant Version: 1.5 alpha (nightly) Platform: All OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Core tasks AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] In org.apache.tools.ant.util.FileUtils there is the method: public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String encoding, Project project) On line 379 & 380 and 392 & 393the in and out streams are closed. The code should be wrapped in try {} finally {} blocks so that the files get closed even if the code above them fails. Normally, this code can fail and noboby will see it because java cleans up open files on exit, however, if you keep ant in memory in a program that has an extended lifecycle, these open files can become problematic. If I may, I'd like to suggest the following code, it will drop an IOException if both close() calls throw IOExceptions, however, I don't think you can write this code safely without redesigning the entire class so that none of the copy methods throw IOException. try { // open streams and do work (right now this code starts on line 341) } finally { try { if (out != null) out.close(); } finally { if (in != null) in.close(); } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
