From 8c521a748ed4a59eeef1cc7818a240779cbe9345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Thu, 9 Oct 2014 15:41:01 +0200 Subject: [PATCH] CodeInsightTestCase: more safe tearDown --- .../codeInsight/CodeInsightTestCase.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index cedfe2d04aa9..e86257d8e36f 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -86,13 +86,19 @@ public abstract class CodeInsightTestCase extends PsiTestCase { @Override protected void tearDown() throws Exception { - FileEditorManager editorManager = FileEditorManager.getInstance(myProject); - VirtualFile[] openFiles = editorManager.getOpenFiles(); - for (VirtualFile openFile : openFiles) { - editorManager.closeFile(openFile); + try { + if (myProject != null) { + FileEditorManager editorManager = FileEditorManager.getInstance(myProject); + VirtualFile[] openFiles = editorManager.getOpenFiles(); + for (VirtualFile openFile : openFiles) { + editorManager.closeFile(openFile); + } + } + } + finally { + myEditor = null; + super.tearDown(); } - myEditor = null; - super.tearDown(); } @Override