[KEYCLOAK-17080] Fix ConcurrentModificationException in the migration to 8.0.0 that was introduced by the streamification work

This commit is contained in:
Stefan Guilhen 2021-02-08 22:46:05 -03:00 committed by Hynek Mlnařík
parent 33bb1fda38
commit bea3410357

View file

@ -28,6 +28,7 @@ import org.keycloak.models.RealmModel;
import org.keycloak.representations.idm.RealmRepresentation;
import java.util.Collections;
import java.util.stream.Collectors;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
@ -78,11 +79,12 @@ public class MigrateTo8_0_0 implements Migration {
}
protected void migrateRealmMFA(RealmModel realm) {
realm.getAuthenticationFlowsStream()
realm.getAuthenticationFlowsStream().collect(Collectors.toList())
.forEach(authFlow ->
realm.getAuthenticationExecutionsStream(authFlow.getId())
.filter(exe -> exe.getRequirement() == AuthenticationExecutionModel.Requirement.CONDITIONAL)
.forEachOrdered(exe -> migrateOptionalAuthenticationExecution(realm, authFlow, exe, true)));
.collect(Collectors.toList())
.forEach(exe -> migrateOptionalAuthenticationExecution(realm, authFlow, exe, true)));
}
public static void migrateOptionalAuthenticationExecution(RealmModel realm, AuthenticationFlowModel parentFlow, AuthenticationExecutionModel optionalExecution, boolean updateOptionalExecution) {