add logging to investigate EA-88298 - assert: RootModelImpl.addLibraryEntry
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Mon, 12 Sep 2016 11:54:55 +0000 (14:54 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Mon, 12 Sep 2016 11:54:55 +0000 (14:54 +0300)
platform/projectModel-impl/src/com/intellij/openapi/roots/impl/RootModelImpl.java

index 9e621cde6b22d3b7d533294b206b6aa2a11e1d49..d35d7ba66f8aaee96152d1d66d8435f1344129a3 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
 import com.intellij.util.ArrayUtil;
+import com.intellij.util.ObjectUtils;
 import com.intellij.util.containers.ContainerUtil;
 import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
@@ -225,7 +226,14 @@ public class RootModelImpl extends RootModelBase implements ModifiableRootModel
   public LibraryOrderEntry addLibraryEntry(@NotNull Library library) {
     assertWritable();
     final LibraryOrderEntry libraryOrderEntry = new LibraryOrderEntryImpl(library, this, myProjectRootManager);
-    assert libraryOrderEntry.isValid();
+    if (libraryOrderEntry.isValid()) {
+      LibraryEx libraryEx = ObjectUtils.tryCast(library, LibraryEx.class);
+      boolean libraryDisposed = libraryEx != null ? libraryEx.isDisposed() : Disposer.isDisposed(library);
+      throw new AssertionError("Invalid libraryOrderEntry, library: " + library
+                               + " of type " + library.getClass()
+                               + ", disposed: " + libraryDisposed
+                               + ", kind: " + (libraryEx != null ? libraryEx.getKind() : "<undefined>"));
+    }
     myOrderEntries.add(libraryOrderEntry);
     return libraryOrderEntry;
   }