Close indexes as they are removed from the IndexCollection

Change-Id: I71cf370be094ae1eba73b2dec9e0dfec3b9a5c09
This commit is contained in:
Dave Borowitz
2013-09-30 17:11:56 -07:00
parent 9577768bf4
commit d57c22d4ee
3 changed files with 11 additions and 3 deletions

View File

@@ -109,7 +109,7 @@ public class LuceneIndexModule extends LifecycleModule {
@Override
public void stop() {
index.close();
// Do nothing; indexes are closed by IndexCollection.
}
}
}

View File

@@ -220,5 +220,6 @@ class LuceneVersionManager implements LifecycleListener {
@Override
public void stop() {
// Do nothing; indexes are closed on demand by IndexCollection.
}
}

View File

@@ -49,7 +49,10 @@ public class IndexCollection implements LifecycleListener {
}
public void setSearchIndex(ChangeIndex index) {
searchIndex.set(index);
ChangeIndex old = searchIndex.getAndSet(index);
if (old != null && old != index) {
old.close();
}
}
public Collection<ChangeIndex> getWriteIndexes() {
@@ -76,7 +79,11 @@ public class IndexCollection implements LifecycleListener {
}
}
if (removeIndex >= 0) {
writeIndexes.remove(removeIndex);
try {
writeIndexes.get(removeIndex).close();
} finally {
writeIndexes.remove(removeIndex);
}
}
}