[
https://issues.apache.org/jira/browse/OAK-3313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14733699#comment-14733699
]
Marcel Reutegger commented on OAK-3313:
---------------------------------------
Thanks for the patch. Looks very useful.
I committed a slightly modified version of your patch:
- Renamed {{DocumentMkBuilderProvider}} to {{DocumentMKBuilderProvider}} and
added a license header
- Added a DocumentStoreWrapper class to address the shutdown issue with
multiple DocumentNodeStore instances sharing the same DocumentStore.
- Reverted changes to {{ValueMapTest}}. AFAICS the store is properly disposed
at the end of the test.
Applied to trunk: http://svn.apache.org/r1701619
> Many tests leak DocumentNodeStore instances
> -------------------------------------------
>
> Key: OAK-3313
> URL: https://issues.apache.org/jira/browse/OAK-3313
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: core
> Reporter: Robert Munteanu
> Assignee: Marcel Reutegger
> Fix For: 1.3.6
>
> Attachments:
> 0001-OAK-3313-Many-tests-leak-DocumentNodeStore-instances.patch
>
>
> Many tests use the {{DocumentMK.Builder}} to create {{DocumentNodeStore}}
> instances in tests. The cleanup is manual, either in an {{@After}} method or
> in the test method. The problems arise when the cleanup is forgotten or not
> done in a finally block. The problem appears when too many threads are
> started but not stopped and hit machine resource limitations.
> To solve this problem I propose using a JUnit {{@Rule}} which returns a
> custom {{DocumentMK.Builder}} instance which shuts down the
> {{DocumentNodeStore}} that it has created when the test method is finished.
> I was able to replace most of the leaks by using the
> {{DocumentMkBuilderProvider}} rule, as follows:
> Before:
> {code}@Test
> public void someTest() {
> DocumentNodeStore = new DocumentMK.Builder().getNodeStore();
> // test code
> store.dispose();
> }{code}
> After:
> {code}
> @Rule
> public DocumentMkBuilderProvider builderProvider = new
> DocumentMkBuilderProvider();
> @Test
> public void someTest() {
> DocumentNodeStore = builderProvider.newBuilder().getNodeStore();
> // test code
> }{code}
> I haven't touched tests which did not leak DocumentNodeStore instances.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)