In some cases the SearchIndexingPlan generate a ConcurrentModificiationException if an embedded entities is not listed in the addOrUpdate or on specific order (if only the last entity is concern this case)
Explanation from @yrodiere :
The problem is probably in org.hibernate.search.mapper.pojo.work.impl.PojoIndexingPlanImpl#process, in this loop:
The call to resolveDirty will trigger a loop on indexingPlansPerId that executes an operation of each element of that map.
The problem is, this operation might trigger the addition of an element to the map indexedTypeDelegates (through org.hibernate.search.mapper.pojo.work.impl.PojoIndexingPlanImpl#getOrCreateIndexedDelegateForContainedUpdate), or to the map indexingPlansPerId (through org.hibernate.search.mapper.pojo.work.impl.PojoIndexedTypeIndexingPlan#getPlan), when we discover a type/entity that wasn’t present in the map initially.
The concurrent modification is not a problem per se, because we don’t need to call resolveDirty on newly added elements. However, it’s a problem because the iterator will detect the concurrent modification and throw an exception.