| We have a lot of cleanup methods that do not account for the possibility of failure. For instance, in IndexManagerHolder.stop():
public synchronized void stop() {
for ( IndexManager indexManager : getIndexManagers() ) {
indexManager.destroy();
}
}
If the first index manager fails to stop, then none of the following index manager will be stopped. But theoretically, they could be completely different implementations, and thus the second index manager may stop perfectly well even if the first one failed. There are many places making a similar mistake, most notably:
- IndexManagerHolder.stop
- Most implementations of Stoppable.stop
- Most implementations of IndexManager.destroy
- ImmutableSearchFactory.close
- SearchIntegratorBuilder.cleanupFactoryState (soon to be merged as part of
HSEARCH-2277 In Progress )
We may want to implement "composite cleanups" in a more reliable way, for instance with a utility object similar to Guava's Closer (see here). Note this class is very simple, we don't need Guava, we can just re-implement it ourselves. |