Skip to content

Commit f5524f0

Browse files
andrusclaude
andcommitted
fix PropertyListSerializationTest file handle leak on Windows
Parser(File) left the FileInputStream open after parsing, preventing @tempdir cleanup on Windows (file locked by another process). Open the stream explicitly in propertyListFromFile so it is closed via try-with-resources after parsing completes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0c56174 commit f5524f0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/PropertyListSerialization.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ public static Object propertyListFromFile(File f, PlistDataStructureFactory fact
6363
throw new FileNotFoundException("No such file: " + f);
6464
}
6565

66-
return new Parser(f, factory).propertyList();
66+
// Use explicit stream so it is closed after parsing; Parser(File) leaves the stream open,
67+
// which prevents temp-directory cleanup on Windows.
68+
try (InputStream in = new java.io.FileInputStream(f)) {
69+
return new Parser(in, factory).propertyList();
70+
} catch (FileNotFoundException e) {
71+
throw e;
72+
} catch (IOException e) {
73+
throw new CayenneRuntimeException("Error reading plist: " + f, e);
74+
}
6775
}
6876

6977
/**

0 commit comments

Comments
 (0)