DisposalException during testing
Hi, i'm writing some tests of my plugin. For those I need to somehow add sources to the project:
val libVFilePointer = VirtualFilePointerManager.getInstance().create("file:///(...)",module,null)
PsiTestUtil.addSourceRoot(module, libVFilePointer.getFile)
The problem is that the exception is thrown. Of course my guess is i need to call .dispose somewhere. Doing so on module causes Already disposed exception. So my next guess is to search for somewhere to register my filepointer, but a glance at the sourcecode discouraged my own explores so I'm asking for help. ;-)
com.intellij.openapi.util.TraceableDisposable$DisposalException: Virtual pointer hasn't been disposed: file:///home/tomaszym/correct/path/to/the/file
--------------Creation trace:
java.lang.Throwable: parent = 'Module: 'light_idea_test_case'' (class com.intellij.openapi.module.impl.ModuleImpl); URL=<null,file:///home/tomaszym/correct/path/to/the/file
at com.intellij.openapi.vfs.impl.VirtualFilePointerImpl.<init>(VirtualFilePointerImpl.java:39)
at com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl.getOrCreate(VirtualFilePointerManagerImpl.java:256)
at com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl.create(VirtualFilePointerManagerImpl.java:198)
at com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl.create(VirtualFilePointerManagerImpl.java:151)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.intellij.testFramework.UsefulTestCase.access$001(UsefulTestCase.java:80)
at com.intellij.testFramework.UsefulTestCase$2.run(UsefulTestCase.java:303)
at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2070)
at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(UsefulTestCase.java:335)
at com.intellij.testFramework.UsefulTestCase.runTest(UsefulTestCase.java:319)
at com.intellij.testFramework.LightPlatformCodeInsightTestCase.access$001(LightPlatformCodeInsightTestCase.java:70)
at com.intellij.testFramework.LightPlatformCodeInsightTestCase.doRunTest(LightPlatformCodeInsightTestCase.java:110)
at com.intellij.testFramework.LightPlatformCodeInsightTestCase$1$1.run(LightPlatformCodeInsightTestCase.java:88)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:99)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:85)
at com.intellij.testFramework.LightPlatformCodeInsightTestCase$1.run(LightPlatformCodeInsightTestCase.java:83)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
at com.intellij.testFramework.LightPlatformCodeInsightTestCase.runTest(LightPlatformCodeInsightTestCase.java:98)
at com.intellij.testFramework.LightPlatformTestCase.startRunAndTear(LightPlatformTestCase.java:695)
at com.intellij.testFramework.LightPlatformTestCase.access$700(LightPlatformTestCase.java:121)
at com.intellij.testFramework.LightPlatformTestCase$8.run(LightPlatformTestCase.java:658)
(at java.awt.....)
-------------Own trace:
com.intellij.openapi.util.TraceableDisposable$DisposalException: Virtual pointer hasn't been disposed: file:///home/tomaszym/correct/path/to/the/file
at com.intellij.openapi.util.TraceableDisposable.throwDisposalError(TraceableDisposable.java:44)
at com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl.assertPointersAreDisposed(VirtualFilePointerManagerImpl.java:328)
at com.intellij.testFramework.LightPlatformTestCase.tearDown(LightPlatformTestCase.java:520)
at com.intellij.testFramework.LightPlatformCodeInsightTestCase.tearDown(LightPlatformCodeInsightTestCase.java:257) at org.jetbrains.plugins.scala.base.ScalaLightPlatformCodeInsightTestCaseAdapter.tearDown(ScalaLightPlatformCodeInsightTestCaseAdapter.java:112)
at com.intellij.testFramework.LightPlatformTestCase.startRunAndTear(LightPlatformTestCase.java:700)
at com.intellij.testFramework.LightPlatformTestCase.access$700(LightPlatformTestCase.java:121)
at com.intellij.testFramework.LightPlatformTestCase$8.run(LightPlatformTestCase.java:658)
(at java.awt.....)
Please sign in to leave a comment.
The beginning of the stacktrace with already disposed:
That's what I've been missing for a while... hope it will be helpful to someone sometime. ;-)