| For instance, these elements are mutated when a new search factory is built, and this mutation affects the old search factory too:
- The index manager holder (org.hibernate.search.engine.impl.ImmutableSearchFactory.getIndexManagerHolder())
- The class hierarchy used to lookup indexed subclasses (org.hibernate.search.engine.impl.ImmutableSearchFactory.indexHierarchy)
- maybe others, too?
Those mutations could in theory result in inconsistent behavior during the building of a new (incremental) search factory, even if it is unlikely to happen in practice. For instance the index hierarchy could report one class as not indexed, while the index manager holder would contain an index manager for this class. A simple solution would be to make the sub-components immutable, and to build new versions of these components when we build new SearchFactories. This would require to make sure nobody keeps a direct reference to the components, though. |