Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisposalException from the plugin in 2021.1 EAP #248

Closed
east825 opened this issue Feb 24, 2021 · 6 comments
Closed

DisposalException from the plugin in 2021.1 EAP #248

east825 opened this issue Feb 24, 2021 · 6 comments

Comments

@east825
Copy link

east825 commented Feb 24, 2021

We get a lot of exception reports like the following in 2021.1 EAP. The easiest way to fix this is to check that an SDK is not disposed in the runnable launched with invokeLater.

com.intellij.openapi.util.TraceableDisposable$DisposalException: Already disposed:
-------------Own trace:
com.intellij.openapi.util.TraceableDisposable$DisposalException: 1581861663
    at com.intellij.openapi.util.TraceableDisposable.getStackTrace(TraceableDisposable.java:120)
    at com.intellij.openapi.vfs.impl.VirtualFilePointerContainerImpl.checkDisposed(VirtualFilePointerContainerImpl.java:389)
    at com.intellij.openapi.vfs.impl.VirtualFilePointerContainerImpl.getOrCache(VirtualFilePointerContainerImpl.java:199)
    at com.intellij.openapi.vfs.impl.VirtualFilePointerContainerImpl.getFiles(VirtualFilePointerContainerImpl.java:290)
    at com.intellij.openapi.projectRoots.impl.RootsAsVirtualFilePointers.getFiles(RootsAsVirtualFilePointers.java:40)
    at com.intellij.openapi.projectRoots.impl.ProjectJdkImpl$MyRootProvider.getFiles(ProjectJdkImpl.java:285)
    at com.jetbrains.python.sdk.PythonSdkUtil.findLibraryDir(PythonSdkUtil.java:226)
    at com.jetbrains.python.sdk.PythonSdkUtil.findSkeletonsDir(PythonSdkUtil.java:217)
    at com.koxudaxi.pydantic.PydanticPackageManagerListener$packagesRefreshed$1.run(PydanticPackageManagerListener.kt:12)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:218)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:200)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:782)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:319)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:972)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:838)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:448)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:447)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:782)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:495)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

    at com.intellij.openapi.util.TraceableDisposable.throwDisposalError(TraceableDisposable.java:86)
    at com.intellij.openapi.vfs.impl.VirtualFilePointerContainerImpl.checkDisposed(VirtualFilePointerContainerImpl.java:389)
    at com.intellij.openapi.vfs.impl.VirtualFilePointerContainerImpl.getOrCache(VirtualFilePointerContainerImpl.java:199)
    at com.intellij.openapi.vfs.impl.VirtualFilePointerContainerImpl.getFiles(VirtualFilePointerContainerImpl.java:290)
    at com.intellij.openapi.projectRoots.impl.RootsAsVirtualFilePointers.getFiles(RootsAsVirtualFilePointers.java:40)
    at com.intellij.openapi.projectRoots.impl.ProjectJdkImpl$MyRootProvider.getFiles(ProjectJdkImpl.java:285)
    at com.jetbrains.python.sdk.PythonSdkUtil.findLibraryDir(PythonSdkUtil.java:226)
    at com.jetbrains.python.sdk.PythonSdkUtil.findSkeletonsDir(PythonSdkUtil.java:217)
    at com.koxudaxi.pydantic.PydanticPackageManagerListener$packagesRefreshed$1.run(PydanticPackageManagerListener.kt:12)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:218)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:200)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:782)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:319)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:972)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:838)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:448)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:447)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:782)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:495)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
@koxudaxi
Copy link
Owner

@east825
Thank you for creating an issue.

The easiest way to fix this is to check that an SDK is not disposed in the runnable launched with invokeLater.

Would you please show me an example?
I don't know how to check SDK is not disposed.

at com.koxudaxi.pydantic.PydanticPackageManagerListener$packagesRefreshed$1.run(PydanticPackageManagerListener.kt:12)

I can catch AlreadyDisposedException and drop it.
But, Is it the correct way?
Also, Do I have to fix it in other places too? I may use SDK in invokeLater in several methods.

@east825
Copy link
Author

east825 commented Feb 25, 2021

Sure, I meant adding something like:

if (sdk is Disposable && Disposer.isDisposed(sdk)) {
    return@invokeLater
}

inside invokeLater in com.koxudaxi.pydantic.PydanticPackageManagerListener#packagesRefreshed.

In general, it's a good idea to do it whenever you need to access an SDK in a postponed/background activity (it might become invalid by this moment).

We actually started getting more of such exceptions in various other places, I'm investigating what's going on. There is likely a deeper problem on our side (apparently, we dispatch events for an already disposed SDK), but this is an easy fix to protect your plugin against it.

@koxudaxi
Copy link
Owner

I have fixed it.
Thank you!!

Did you get the error report by users?
Would you please share the issue if the ticket of issue exits on youtrack?

@east825
Copy link
Author

east825 commented Feb 26, 2021 via email

@koxudaxi
Copy link
Owner

I see. Thank you

@koxudaxi
Copy link
Owner

The Fixed version has been published in the market.
Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants