Closed abrokenjester closed 4 years ago
Thanks for the report @jeenbroekstra
I make TestSource
AutoClosable which closes any open QueryExecutionFactory objects. When RDFUnit is used as a library the developer would be responsible for closing this (or instantiating it with try-with-resources).
Does this approach cover your use cases? if not, you can reopen the issue and we can find another solution
Thanks for looking into this @jimkont. I think your fixes cover some cases, but there are a few other places where autocloseables are leaking - mainly because they are being daisy-chained in the try block instead of independently assigned. Let me put a PR together for you.
Ah, hang on, I missed the bit where you fixed the close method in AbstractTestSource. Spoke too soon, this might cover our case (though part of the problem is that we use a custom implementation of TestSource that does not inherit from AbstractTestSource).
Thanks! Any contribution/PR of of course more than welcome!
Would also be happy to refactor TestSource / AbstractTestSource if it results in a design that covers more use cases
Expected Behavior
org.aksw.jena_sparql_api.core.QueryExecutionFactory
implementsAutoCloseable
. Any code that uses an instance of this class should take care that theclose()
method is called so that internal resources can be cleaned up. This can be achieved by either manually callingclose()
or by making the creation part of a try-with-resources construct.Actual Behavior
In several places in AggregatedTestExecutor and other executors,
Testsource.getExecutionFactory
is called on the fly. It is not part of a try-with-resources construct. The result is that theclose()
method is never called on these instances. For implementations ofQueryExecutionFactory
that have internal resources (such as open database connections), this is problematic.