From b6a8892536fc32e6fecb7bc135409c6ff74f4448 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 28 Dec 2016 09:44:46 +0100 Subject: [PATCH] platform: synchronize access to ModuleRootManagerImpl.myModelCreations 'getModifiableModel' requires read access only so it may be invoked concurrently. --- .../openapi/roots/impl/ModuleRootManagerImpl.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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; }