Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-17127

[REL] Migration to Keycloak 12 fails with ConcurrentModificationException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 12.0.2
    • Fix Version/s: 12.0.3
    • Component/s: Core
    • Labels:
      None

      Description

      When migrating from Keycloak 4.8.3 (or any version prior to Keycloak 8.0.0, which introduces multi-factor authentication) to Keycloak 12, authentication flows that contain executions whose requirement is OPTIONAL are not properly migrated and the process fails with a ConcurrentModificationException:

       

      15:31:41,137 FATAL [org.keycloak.services] (ServerService Thread Pool -- 64) Error during startup: java.util.ConcurrentModificationException 
      at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) at java.util.ArrayList$Itr.next(ArrayList.java:859) 
      at org.hibernate.collection.internal.AbstractPersistentCollection$IteratorProxy.next(AbstractPersistentCollection.java:879) 
      at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) 
      at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) 
      at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) 
      at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) 
      at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) 
      at org.keycloak.migration.migrators.MigrateTo8_0_0.migrateRealmMFA(MigrateTo8_0_0.java:82) 
      at org.keycloak.migration.migrators.MigrateTo8_0_0.lambda$migrate$0(MigrateTo8_0_0.java:51)
      

       

      The issue lies in MigrateTo8_0_0.migrateRealmMFA method that iterates through live streams while calling a method that ends up modifying the streams' source. More specifically, the method is adding new authentication flows and executions to the realm while iterating through the flows and executions streams created by the realm.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sguilhen Stefan Guilhen
              Reporter:
              sguilhen Stefan Guilhen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: