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.