[ 
https://issues.apache.org/jira/browse/SOLR-9406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joel Bernstein updated SOLR-9406:
---------------------------------
    Description: 
Currently this is the code for registering a close hook for SolrSuggester:

{code}
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) {}
    });
{code}

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. 

  was:
Currently this is the code for registering a close hook for the solr suggester:

{code}
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) {}
    });
{code}

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. 


> SolrSuggester should selectively register close hook
> ----------------------------------------------------
>
>                 Key: SOLR-9406
>                 URL: https://issues.apache.org/jira/browse/SOLR-9406
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: Suggester
>    Affects Versions: 4.10.3
>            Reporter: Gethin James
>         Attachments: SOLR-9406.patch
>
>
> Currently this is the code for registering a close hook for SolrSuggester:
> {code}
> 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) {}
>     });
> {code}
> 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. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to