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

SolrSuggester should selectively register close hook

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Resolved
    • Affects Version/s: 4.10.3
    • Fix Version/s: 6.3
    • Component/s: Suggester
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      Currently this is the code for registering a close hook for SolrSuggester:

      lookup = factory.create(config, core);
          core.addCloseHook(new CloseHook() {
            @Override
            public void preClose(SolrCore core) {
              if (lookup != null && lookup instanceof Closeable) {
                try {
                  ((Closeable) lookup).close();
                } catch (IOException e) {
                  LOG.warn("Could not close the suggester lookup.", e);
                }
              }
            }
            
            @Override
            public void postClose(SolrCore core) {}
          });
      

      Notice that the close hook is always registered, even though the close logic runs conditionally.

      This can be changed so that the close hook is registered conditionally.

      This will help avoid memory leaks in scenarios where a custom component reloads the SolrSuggester multiple times for the same core.

        Attachments

        1. SOLR-9406.patch
          1 kB
          Joel Bernstein

          Activity

            People

            • Assignee:
              joel.bernstein Joel Bernstein
              Reporter:
              covolution Gethin James
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: