diagnostics for EditorHistoryManagerTest.testSavingStateForNotOpenedEditors

This commit is contained in:
Sergey Ignatov
2018-11-20 15:32:27 +03:00
parent 49ce7cebce
commit 44ffc93d00
@@ -1,6 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.fileEditor.impl;
import com.intellij.diagnostic.ThreadDumper;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.components.impl.ComponentManagerImpl;
@@ -22,6 +23,7 @@ import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.lang.ref.WeakReference;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
@@ -45,11 +47,22 @@ public class EditorHistoryManagerTest extends PlatformTestCase {
FileEditorManager.getInstance(project).closeFile(virtualFile);
});
String threadDumpBefore = ThreadDumper.dumpThreadsToString();
GCUtil.tryGcSoftlyReachableObjects();
WeakReference<Object> weakReference = new WeakReference<>(new Object());
do {
//noinspection CallToSystemGC
System.gc();
}
while (weakReference.get() != null);
Document document = FileDocumentManager.getInstance().getCachedDocument(virtualFile);
if (document != null) {
fail("Document wasn't collected, see heap dump at " + publishHeapDump(EditorHistoryManagerTest.class.getName()));
System.out.println("Keeping a reference to the document: " + document);
System.err.println("Keeping a reference to the document: " + document);
System.err.println(threadDumpBefore);
}
openProjectPerformTaskCloseProject(dir, project -> {});