Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-3313

Many tests leak DocumentNodeStore instances

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0.21, 1.2.6, 1.3.6, 1.4
    • core
    • None

    Description

      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:

      @Test
       public void someTest() {
            DocumentNodeStore = new DocumentMK.Builder().getNodeStore();
            // test code
           store.dispose();
        }

      After:

      @Rule
      public DocumentMkBuilderProvider builderProvider = new DocumentMkBuilderProvider();
      @Test
       public void someTest() {
            DocumentNodeStore = builderProvider.newBuilder().getNodeStore();
            // test code
        }

      I haven't touched tests which did not leak DocumentNodeStore instances.

      Attachments

        Activity

          People

            mreutegg Marcel Reutegger
            rombert Robert Munteanu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: