You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Mark Murphy <jm...@gmail.com> on 2018/02/11 22:11:06 UTC

Tests that create documents without closing them

Has anyone noticed that we have a lot of test cases that create documents
without closing them when they are complete? Does this happen automatically
somehow, and I just missed it, or are we using up a lot of memory by
keeping documents open?

Re: Tests that create documents without closing them

Posted by Javen O'Neal <on...@apache.org>.
Yes.. many tests were written without closing the document.

Some tests close documents outside of a finally statement and thus won't
close the document if the unit test fails.

When the JVM exits, it should close any open resources that the unit tests
failed to close. This would be really bad for production code where the JVM
may run continuously, but hasn't been a big deal for test code. Every line
of test code that doesn't directly relate to what's being tested could be
viewed as noise, but I'm in favor of unit tests properly closing resources
since the unit tests also serve as a reference implementation/quick guide
for users of our library, and proper resource management should be used
whenever possible.

Feel free to fix the resource leaks in the unit tests as you discover them.
Even if done without proper try/finally or try-with-resources/finally.

On Feb 11, 2018 14:11, "Mark Murphy" <jm...@gmail.com> wrote:

> Has anyone noticed that we have a lot of test cases that create documents
> without closing them when they are complete? Does this happen automatically
> somehow, and I just missed it, or are we using up a lot of memory by
> keeping documents open?
>