ConcurrentModification at switching provider fixed

This fixes bug 5237.
Merge branch 'bug/dying-client-during-configuration-5237' into develop