Apache Solr open-source search software
SOLR-4213: Directories that are not shutdown until DirectoryFactory#close do not have close listeners called on them.
Mark Robert Millere40696cd81f5
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex dbb00cdd2a6..5aea33ab2f7 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -369,6 +369,9 @@ Bug Fixes* SOLR-4198: OverseerCollectionProcessor should implement ClosableThread.(Mark Miller)+* SOLR-4213: Directories that are not shutdown until DirectoryFactory#close+ do not have close listeners called on them. (Mark Miller)+Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.javaindex d20992d4f25..2c02d0e09f3 100644--- a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java+++ b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java@@ -138,7 +138,7 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {assert val.refCnt == 0 : val.refCnt;log.info("Closing directory when closing factory:" + val.path);- val.directory.close();+ closeDirectory(val);} catch (Throwable t) {SolrException.log(log, "Error closing directory", t);}@@ -164,31 +164,34 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {if (cacheValue.refCnt == 0 && cacheValue.doneWithDir) {log.info("Closing directory:" + cacheValue.path);- List<CloseListener> listeners = closeListeners.remove(directory);- if (listeners != null) {- for (CloseListener listener : listeners) {- listener.preClose();- }- }- try {- log.info("Closing directory:" + cacheValue.path);- directory.close();- } catch (Throwable t) {- SolrException.log(log, "Error closing directory", t);- }-- if (listeners != null) {- for (CloseListener listener : listeners) {- listener.postClose();- }- closeListeners.remove(directory);- }+ closeDirectory(cacheValue);byDirectoryCache.remove(directory);byPathCache.remove(cacheValue.path);}}}++ private void closeDirectory(CacheValue cacheValue) {+ List<CloseListener> listeners = closeListeners.remove(cacheValue.directory);+ if (listeners != null) {+ for (CloseListener listener : listeners) {+ listener.preClose();+ }+ }+ try {+ log.info("Closing directory:" + cacheValue.path);+ cacheValue.directory.close();+ } catch (Throwable t) {+ SolrException.log(log, "Error closing directory", t);+ }++ if (listeners != null) {+ for (CloseListener listener : listeners) {+ listener.postClose();+ }+ }+ }@Overrideprotected abstract Directory create(String path) throws IOException;