Closed EliyahuStern closed 6 years ago
Suggested test case:
public static void testDeleteAfterParse() throws Exception {
File f = new File("test-files/toDelete1.plist");
NSDictionary d = (NSDictionary)PropertyListParser.parse(f);
assertTrue(f.delete());
}
Thank you for bringing this to my attention. I adjusted all places where input and output streams are handled making sure file resources are released.
Happy to help. Thanks for publishing and maintaining such a useful repo!
The parser / writer methods receiving a File object, creates streams and never / improperly close them, causing resource leaks.
For instance: BinaryPropertyListParser - The FileInputStream is never closed. BinaryPropertyListWriter - The FileOutputStream is closed, but with no
try\finally
block.These open files can cause all sort of weird behaviors, such as running out of file descriptors, or inability to move/delete the file after reading/writing.
It is required (since it is Java 1.5) to use the try-finally pattern to close the streams: