[foreign-jextract] Integrated: 8250774: jextract does not close all files
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Wed Jul 29 14:49:12 UTC 2020
Since when we switched to the new jextract implementation, we have observed spurious test failures on windows, caused
by the fact that some of the files generated by jextract test runs are left opened and, therefore, cannot be deleted.
I have investigated this matter further (on Linux), by debugging one of the failing test (UnionDeclTest) and using
`lsof` to keep track of the list of opened file descriptors associated with the test process. What I discovered was
that calling `Writer::writeClassFiles` was causing the leak; upon closer inspection, I found this dubious code:
Files.write(fullPath, entry.openInputStream().readAllBytes());
In other words, the input stream was not being closed. As per javadoc, `readAllBytes` does _not_ close the stream when
done. Fixing this (by using a try with resources) seems to get rid of the issues, and the leaked descriptors are no
longer visible using `lsof`.
-------------
Commit messages:
- Fix missing input stream close
Changes: https://git.openjdk.java.net/panama-foreign/pull/271/files
Webrev: https://webrevs.openjdk.java.net/panama-foreign/271/webrev.00
Issue: https://bugs.openjdk.java.net/browse/JDK-8250774
Stats: 4 lines in 1 file changed: 3 ins; 0 del; 1 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/271.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/271/head:pull/271
PR: https://git.openjdk.java.net/panama-foreign/pull/271
More information about the panama-dev
mailing list