[foreign-jextract] Integrated: 8250774: jextract does not close all files
Athijegannathan Sundararajan
sundar at openjdk.java.net
Wed Jul 29 14:49:12 UTC 2020
On Wed, 29 Jul 2020 11:28:56 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> 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`.
Marked as reviewed by sundar (Committer).
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/271
More information about the panama-dev
mailing list