[ 
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 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. 

  was:
SolrSuggester init method register a CloseHook keeping a reference to 
LookupFactory.

If init() is called multiple times then multiple close hooks are added.  These 
are kept in memory and not reclaimed.

See https://issues.alfresco.com/jira/browse/ACE-5148


> 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
>
> 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. 



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to