Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-15085

EmbeddedSolrServer calls shutdown on a provided CoreContainer

    XMLWordPrintableJSON

    Details

      Description

      There are essentially 2 ways to create an EmbeddedSolrServer object, one by passing in a CoreContainer object, and the other way creates one internally on-the-fly. The current behaviour of the close method calls shutdown on the CoreContainer, regardless of where it came from.

      I believe this is not good behaviour for a class that doesn't control the lifecycle of the passed-in CoreContainer. In fact, there are 4 cases among the codebase where a subclass of EmbeddedSolrServer is created just to override this behaviour (with a comment saying it's unwanted).

      In my use-case I create EmbeddedSolrServer instances for cores as and when I need to work with them, but the CoreContainer exists for the duration. I don't want the whole container shut down when I'm done with just one of its cores. You can workaround it by just not calling close on the EmbeddedSolrServer object, but that's risky especially if you use a try-with-resources as close is called automatically then.

      Fix is to keep track of whether the CoreContainer was created internally or not, and only shut it down if internal. I will attach my patch PR.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mdrob Mike Drob
                Reporter:
                TimOwen Tim Owen
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m