The class org.dspace.authority.indexer.DSpaceAuthorityIndexer needs to be overhauled. As a follow-up of
DS-3680 we need a better cache handling in the Indexer. Furthermore the indexer uses an item and an itemIterator as class variables which may not be thread-safe, depending on how the iterator is constructed. As long as it was used from the command line interface only, that may have bin fine, but as it is also started by the AuthorityConsumer which runs inside a web session, we need to ensure it is thread-safe.
DS-3680 we tried to deal with a StaleStateException when the AuthorityConsumer was running. The Exception resulted in a call to Context.uncacheEntity(). When indexing a whole repository it is important to uncache items, when being started from the AuthorityConsumer we should not uncache the item. Probably a good solution would be to change how items to index are given to the indexer, so that we can uncache items in the class that performs the command line interface for indexing a whole repository.