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

Fix ActionUpdateThread deprecation error for IntelliJ 2024.x+ #1631

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vnoctem
Copy link

@vnoctem vnoctem commented Sep 26, 2024

This PR fixes the deprecation of ActionUpdateThread.OLD_EDT, which causes errors like this in IntelliJ IDEA 2024.x+:

com.intellij.diagnostic.PluginException: `ActionUpdateThread.OLD_EDT` is deprecated and going to be removed soon. 'org.jetbrains.plugins.spotbugs.actions.ClearAndCloseToolWindow' must override `getActionUpdateThread()` and chose EDT or BGT. See ActionUpdateThread javadoc. [Plugin: org.jetbrains.plugins.spotbugs]
	at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
	at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:90)
	at com.intellij.diagnostic.PluginException.reportDeprecatedUsage(PluginException.java:125)
	at com.intellij.openapi.actionSystem.ActionUpdateThreadAware.getActionUpdateThread(ActionUpdateThreadAware.java:21)
	at com.intellij.openapi.actionSystem.AnAction.getActionUpdateThread(AnAction.java:201)

To resolve this, I've overridden getActionUpdateThread() in AbstractAction and AbstractToggleAction, defaulting to EDT for actions that involve UI interactions. However, I haven’t extensively tested all actions, and feedback on whether some should run on BGT would be appreciated.

The fix is backwards compatible with IntelliJ IDEA 2022.2 (222.3345.118 build) and higher and should take care of the deprecation errors in 2024.x.

Issues related

Fix #1627, Fix #1624, Fix #1622, Fix #1612

@Shadow-Devil
Copy link

@amaembo could you please review this? This error is really annoying and a lot of users are experiencing it.

@Tachi107
Copy link

Hi, I've been using the SpotBugs plugin for a while with this patch, thanks for that!

Still, today I've encountered an error which looks like it may be related to your changes. I don't remember what I did to trigger it, but I'll leave the stack trace below:

com.intellij.diagnostic.PluginException: PSI element is provided on EDT by org.jetbrains.plugins.spotbugs.gui.tree.view.BugTree.getData("psi.Element"). Please move that to a BGT data provider using PlatformCoreDataKeys.BGT_DATA_PROVIDER [Plugin: org.jetbrains.plugins.spotbugs]
	at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
	at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:90)
	at com.intellij.ide.impl.DataValidators.reportPsiElementOnEdt(DataValidators.java:106)
	at com.intellij.ide.impl.DataValidators.isDataValid(DataValidators.java:80)
	at com.intellij.ide.impl.DataValidators.validOrNull(DataValidators.java:73)
	at com.intellij.openapi.actionSystem.impl.PreCachedDataContext$MySink.set(PreCachedDataContext.java:437)
	at com.intellij.openapi.actionSystem.impl.PreCachedDataContext$MySink.uiDataSnapshot(PreCachedDataContext.java:511)
	at com.intellij.openapi.actionSystem.DataSink$Companion.uiDataSnapshot(UiDataProvider.kt:212)
	at com.intellij.openapi.actionSystem.DataSink.uiDataSnapshot(UiDataProvider.kt)
	at com.intellij.openapi.actionSystem.impl.PreCachedDataContext.cacheProviderData(PreCachedDataContext.java:358)
	at com.intellij.openapi.actionSystem.impl.PreCachedDataContext.cacheComponentsData(PreCachedDataContext.java:344)
	at com.intellij.openapi.actionSystem.impl.PreCachedDataContext.<init>(PreCachedDataContext.java:106)
	at com.intellij.openapi.actionSystem.impl.Utils.createAsyncDataContext(Utils.kt:160)
	at com.intellij.openapi.fileEditor.impl.IdeUiServiceImpl.createUiDataContext(IdeUiServiceImpl.java:79)
	at com.intellij.ide.impl.DataManagerImpl.getDataContext(DataManagerImpl.java:296)
	at com.intellij.ide.impl.DataManagerImpl.getDataContext(DataManagerImpl.java:322)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.kt:295)
	at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.kt:620)
	at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$15(IdeEventQueue.kt:582)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:582)
	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:73)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:357)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:356)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:356)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:351)
	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke$lambda$0(IdeEventQueue.kt:1035)
	at com.intellij.openapi.application.WriteIntentReadAction.lambda$run$0(WriteIntentReadAction.java:24)
	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteIntentReadAction(ApplicationImpl.java:910)
	at com.intellij.openapi.application.WriteIntentReadAction.compute(WriteIntentReadAction.java:55)
	at com.intellij.openapi.application.WriteIntentReadAction.run(WriteIntentReadAction.java:23)
	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1036)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:114)
	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1036)
	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$10(IdeEventQueue.kt:351)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:397)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

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