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

IDEA 2022.3启动时报错 #73

Closed
hnyyghk opened this issue Dec 3, 2022 · 2 comments · Fixed by #75
Closed

IDEA 2022.3启动时报错 #73

hnyyghk opened this issue Dec 3, 2022 · 2 comments · Fixed by #75

Comments

@hnyyghk
Copy link
Contributor

hnyyghk commented Dec 3, 2022

版本IntelliJ IDEA 2022.3 (Ultimate Edition)
Build #IU-223.7571.182, built on November 29, 2022
启动时报错

image

报错信息如下:

java.lang.Throwable: Activities registered via registerPostStartupActivity must be dumb-aware: com.intellij.util.DisposeAwareRunnable@2ded0969
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
	at com.intellij.ide.startup.impl.StartupManagerImpl.registerPostStartupActivity(StartupManagerImpl.kt:132)
	at jiux.net.plugin.utils.ToolkitUtil.runWhenInitialized(ToolkitUtil.java:35)
	at jiux.net.plugin.restful.navigator.RestServicesNavigator.initComponent(RestServicesNavigator.java:102)
	at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:45)
	at com.intellij.serviceContainer.BaseComponentAdapter.doCreateInstance(BaseComponentAdapter.kt:145)
	at com.intellij.serviceContainer.BaseComponentAdapter.createInstance$lambda-1(BaseComponentAdapter.kt:124)
	at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:99)
	at com.intellij.serviceContainer.BaseComponentAdapter.createInstance(BaseComponentAdapter.kt:123)
	at com.intellij.serviceContainer.BaseComponentAdapter.access$createInstance(BaseComponentAdapter.kt:19)
	at com.intellij.serviceContainer.BaseComponentAdapter$getInstanceAsync$2.invokeSuspend(BaseComponentAdapter.kt:172)
	at com.intellij.serviceContainer.BaseComponentAdapter$getInstanceAsync$2.invoke(BaseComponentAdapter.kt)
	at com.intellij.serviceContainer.BaseComponentAdapter$getInstanceAsync$2.invoke(BaseComponentAdapter.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceAsync(BaseComponentAdapter.kt:167)
	at com.intellij.serviceContainer.ComponentManagerImpl.createComponentsNonBlocking(ComponentManagerImpl.kt:434)
	at com.intellij.serviceContainer.ComponentManagerImpl$createComponentsNonBlocking$1.invokeSuspend(ComponentManagerImpl.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

对比了com.jetbrains:ideaIU:2022.2.4和2022.3的StartupManagerImpl中registerPostStartupActivity方法
发现该方法在2022.3去除了针对非DumbAware的Runnable支持,warn也改为了error
并且该方法已经被标记为过时,建议使用runAfterOpened,这个方法自2020.1 (201.6668.113 build)可用

image

image

image

将registerPostStartupActivity方法修改为runAfterOpened后依然有报错

image

报错信息如下:

Access is allowed from event dispatch thread only

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: EventQueue.isDispatchThread()=false
Current thread: Thread[DefaultDispatcher-worker-45,5,main] 383263985
SystemEventQueueThread: Thread[AWT-EventQueue-0,6,main] 2010997323
	at com.intellij.openapi.application.impl.ApplicationImpl.throwThreadAccessException(ApplicationImpl.java:1042)
	at com.intellij.openapi.application.impl.ApplicationImpl.assertIsDispatchThread(ApplicationImpl.java:1025)
	at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow(ToolWindowManagerImpl.kt:1014)
	at com.jetbrains.rdserver.toolWindow.BackendServerToolWindowManager.registerToolWindow(BackendServerToolWindowManager.kt:103)
	at com.intellij.openapi.wm.ToolWindowManager.registerToolWindow(ToolWindowManager.kt:62)
	at jiux.net.plugin.restful.navigator.RestServicesNavigator.initToolWindow(RestServicesNavigator.java:119)
	at jiux.net.plugin.restful.navigator.RestServicesNavigator.lambda$initComponent$0(RestServicesNavigator.java:106)
	at com.intellij.util.DisposeAwareRunnable.run(DisposeAwareRunnable.java:72)
	at com.intellij.ide.startup.impl.StartupManagerImpl$runActivities$3$1.invoke(StartupManagerImpl.kt:387)
	at com.intellij.ide.startup.impl.StartupManagerImpl$runActivities$3$1.invoke(StartupManagerImpl.kt:386)
	at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda-0(cancellation.kt:17)
	at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
	at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
	at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:142)
	at com.intellij.ide.startup.impl.StartupManagerImpl.runActivities(StartupManagerImpl.kt:386)
	at com.intellij.ide.startup.impl.StartupManagerImpl.runPostStartupActivitiesRegisteredDynamically(StartupManagerImpl.kt:356)
	at com.intellij.ide.startup.impl.StartupManagerImpl.runPostStartupActivities(StartupManagerImpl.kt:308)
	at com.intellij.ide.startup.impl.StartupManagerImpl.access$runPostStartupActivities(StartupManagerImpl.kt:66)
	at com.intellij.ide.startup.impl.StartupManagerImpl$runStartupActivities$2.invokeSuspend(StartupManagerImpl.kt:184)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

似乎是初始化太早了,注释掉runWhenInitialized方法中的这四行,统一走下面的invokeLater方法,报错消失

        if (!project.isInitialized()) {
            StartupManager.getInstance(project).runAfterOpened(DisposeAwareRunnable.create(r, project));
            return;
        }

测试的过程中,仅出现过一次如下报错

java.lang.IllegalStateException: You must not register toolwindow programmatically so early. Rework code or use ToolWindowManager.invokeLater
	at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.getDefaultToolWindowPaneIfInitialized(ToolWindowManagerImpl.kt:558)
	at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow(ToolWindowManagerImpl.kt:1018)
	at com.jetbrains.rdserver.toolWindow.BackendServerToolWindowManager.registerToolWindow(BackendServerToolWindowManager.kt:103)
	at com.intellij.openapi.wm.ToolWindowManager.registerToolWindow(ToolWindowManager.kt:62)
	at jiux.net.plugin.restful.navigator.RestServicesNavigator.initToolWindow(RestServicesNavigator.java:119)
	at jiux.net.plugin.restful.navigator.RestServicesNavigator.lambda$initComponent$0(RestServicesNavigator.java:106)
	at com.intellij.util.DisposeAwareRunnable.run(DisposeAwareRunnable.java:72)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
	at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:813)
	at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:429)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:74)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:114)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:36)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:909)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:756)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:774)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
	at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:813)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480)
	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)

也是由于初始化早于toolWindowPane导致的,需要修改为ToolWindowManager.invokeLater

hnyyghk added a commit to hnyyghk/RestfulToolkitX that referenced this issue Dec 3, 2022
@Jeanbin520
Copy link

同样遇到这个问题。 大佬怎么解决的 ?

hnyyghk added a commit to hnyyghk/RestfulToolkitX that referenced this issue Dec 5, 2022
hnyyghk added a commit to hnyyghk/RestfulToolkitX that referenced this issue Dec 5, 2022
hnyyghk added a commit to hnyyghk/RestfulToolkitX that referenced this issue Dec 5, 2022
hnyyghk added a commit to hnyyghk/RestfulToolkitX that referenced this issue Dec 5, 2022
@hnyyghk
Copy link
Contributor Author

hnyyghk commented Dec 5, 2022

同样遇到这个问题。 大佬怎么解决的 ?

我自己编译了个测试版本,能正常启动了
https://github.com/hnyyghk/RestfulToolkitX/releases/tag/v2.0.8-test
代码改动已经发起PR

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

Successfully merging a pull request may close this issue.

2 participants