diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java index 06aefe2e61ab..b87daa531d44 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerImpl.java @@ -89,8 +89,11 @@ public class ModuleRootManagerImpl extends ModuleRootManager implements Disposab myIsDisposed = true; if (Disposer.isDebugMode()) { - final Set> entries = myModelCreations.entrySet(); - for (final Map.Entry entry : new ArrayList<>(entries)) { + List> entries; + synchronized (myModelCreations) { + entries = new ArrayList<>(myModelCreations.entrySet()); + } + for (final Map.Entry entry : entries) { System.err.println("***********************************************************************************************"); System.err.println("*** R O O T M O D E L N O T D I S P O S E D ***"); System.err.println("***********************************************************************************************"); @@ -115,7 +118,9 @@ public class ModuleRootManagerImpl extends ModuleRootManager implements Disposab public void dispose() { super.dispose(); if (Disposer.isDebugMode()) { - myModelCreations.remove(this); + synchronized (myModelCreations) { + myModelCreations.remove(this); + } } for (OrderEntry entry : ModuleRootManagerImpl.this.getOrderEntries()) { @@ -124,7 +129,9 @@ public class ModuleRootManagerImpl extends ModuleRootManager implements Disposab } }; if (Disposer.isDebugMode()) { - myModelCreations.put(model, new Throwable()); + synchronized (myModelCreations) { + myModelCreations.put(model, new Throwable()); + } } return model; }