krasa / EclipseCodeFormatter

IntelliJ plugin - use Eclipse's code formatter directly from IntelliJ. https://plugins.jetbrains.com/plugin/6546
Apache License 2.0
487 stars 117 forks source link

IconDeferrerImpl.clearCache IllegalStateException #260

Closed brunpoern closed 1 year ago

brunpoern commented 1 year ago

Hi,

What steps will reproduce the issue?

Not sure exactly but after updating to Intellij 2023.2 I get the error quite often when editing Java or Groovy files.

What happens?

IntelliJ shows the IDE Internal Errors popup with the following stacktrace:

An invalid state was detected that occurs if the key's equals or hashCode was modified while it resided in the cache. This violation of the Map  contract can lead to non-deterministic behavior (key: com.intellij.psi.impl.ElementBase$ElementIconRequest@e023d1cf, key type: ElementIconRequest, node type: PSMS, cache type: SSMS).

  java.lang.IllegalStateException
at com.github.benmanes.caffeine.cache.BoundedLocalCache.logIfAlive(BoundedLocalCache.java:302)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.removeNode(BoundedLocalCache.java:2140)
at com.github.benmanes.caffeine.cache.BoundedLocalCache.clear(BoundedLocalCache.java:2069)
at com.github.benmanes.caffeine.cache.LocalManualCache.invalidateAll(LocalManualCache.java:146)
at com.intellij.ui.IconDeferrerImpl.clearCache(IconDeferrerImpl.kt:66)
at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:696)
at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:659)
at com.intellij.util.messages.impl.MessageBusImplKt.executeOrAddToQueue(MessageBusImpl.kt:491)
at com.intellij.util.messages.impl.ToParentMessagePublisher.publish$intellij_platform_core(MessageBusImpl.kt:530)
at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:448)
at jdk.proxy2/jdk.proxy2.$Proxy97.modificationCountChanged(Unknown Source)
at com.intellij.psi.impl.PsiModificationTrackerImpl.fireEvent(PsiModificationTrackerImpl.java:82)
at com.intellij.psi.impl.PsiModificationTrackerImpl.incCountersInner(PsiModificationTrackerImpl.java:87)
at com.intellij.psi.impl.PsiModificationTrackerImpl.treeChanged(PsiModificationTrackerImpl.java:97)
at com.intellij.psi.impl.PsiManagerImpl.fireEvent(PsiManagerImpl.java:339)
at com.intellij.psi.impl.PsiManagerImpl.beforeChildrenChange(PsiManagerImpl.java:232)
at com.intellij.pom.core.impl.PomModelImpl.sendBeforeChildrenChangeEvent(PomModelImpl.java:346)
at com.intellij.pom.core.impl.PomModelImpl.startTransaction(PomModelImpl.java:279)
at com.intellij.pom.core.impl.PomModelImpl.lambda$runTransaction$2(PomModelImpl.java:96)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeNonCancelableSection$3(CoreProgressManager.java:222)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:628)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$computeInNonCancelableSection$4(CoreProgressManager.java:230)
at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:60)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeInNonCancelableSection(CoreProgressManager.java:230)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:221)
at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:93)
at com.intellij.psi.impl.DiffLog.lambda$doActualPsiChange$0(DiffLog.java:242)
at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.lambda$performActionWithFormatterDisabled$4(CodeStyleManagerImpl.java:428)
at com.intellij.psi.impl.source.PostprocessReformattingAspectImpl.disablePostprocessFormattingInside(PostprocessReformattingAspectImpl.java:129)
at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:456)
at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:427)
at jdk.internal.reflect.GeneratedMethodAccessor742.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at krasa.formatter.plugin.ProxyCodeStyleManagerDelegator.PLEASE_REPORT_BUGS_TO_JETBRAINS_IF_IT_FAILS_HERE____ORIGINAL_INTELLIJ_FORMATTER_WAS_USED(ProxyCodeStyleManagerDelegator.java:60)
at krasa.formatter.plugin.ProxyCodeStyleManagerDelegator.invoke(ProxyCodeStyleManagerDelegator.java:28)
at net.sf.cglib.empty.Object$$EnhancerByCGLIB$$a6c18dd5.performActionWithFormatterDisabled(<generated>)
at com.intellij.psi.impl.DiffLog.doActualPsiChange(DiffLog.java:230)
at com.intellij.psi.impl.DocumentCommitThread.lambda$doCommit$5(DocumentCommitThread.java:302)
at com.intellij.psi.impl.PsiDocumentManagerBase.commitToExistingPsi(PsiDocumentManagerBase.java:425)
at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$finishCommitInWriteAction$5(PsiDocumentManagerBase.java:399)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$computeInNonCancelableSection$4(CoreProgressManager.java:230)
at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:64)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeInNonCancelableSection(CoreProgressManager.java:230)
at com.intellij.psi.impl.PsiDocumentManagerBase.lambda$finishCommitInWriteAction$6(PsiDocumentManagerBase.java:394)
at com.intellij.psi.impl.PsiDocumentManagerBase.executeInsideCommit(PsiDocumentManagerBase.java:510)
at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommitInWriteAction(PsiDocumentManagerBase.java:392)
at com.intellij.psi.impl.PsiDocumentManagerImpl.finishCommitInWriteAction(PsiDocumentManagerImpl.java:136)
at com.intellij.psi.impl.PsiDocumentManagerBase$2.run(PsiDocumentManagerBase.java:359)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:992)
at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommit(PsiDocumentManagerBase.java:356)
at com.intellij.psi.impl.DocumentCommitThread.lambda$commitUnderProgress$2(DocumentCommitThread.java:140)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$safeTransferToEdt$7(NonBlockingReadActionImpl.java:708)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:208)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:190)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:478)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:121)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:789)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)
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:759)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:589)
at com.intellij.openapi.application.impl.ApplicationImpl.runWithoutImplicitRead(ApplicationImpl.java:1485)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:589)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
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)

On the first view formatting functionality seems not to be affected, i.e. source code is still reformatted.

Paste information about IDE and OS (it can be copied from Help | About dialog).

IntelliJ IDEA 2023.2 (Ultimate Edition) Build #IU-232.8660.185, built on July 26, 2023 Expiration date: July 29, 2023 Runtime version: 17.0.7+7-b1000.6 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10.0 Jenkins Plugin 0.13.18-2023.2 GC: G1 Young Generation, G1 Old Generation Memory: 16384M Cores: 12 Registry: debugger.new.tool.window.layout=true ide.experimental.ui=true

Non-Bundled Plugins: com.sdadas.jasypt (0.9.3) ru.sadv1r.ansible-vault-editor-idea-plugin (1.20) ir.msdehghan.plugins.ansible (0.92) de.achimonline.ansible_lint (1.5.3) com.intellij.kubernetes (232.8660.158) EclipseCodeFormatter (23.2.223.000.0-Eclipse_2023-03) com.intellij.spring.shell (232.8660.142) VisualVMLauncher (1.21.211.6085.0) String Manipulation (9.10.0) Jenkins Control Plugin (0.13.18-2023.2) org.asciidoctor.intellij.asciidoc (0.38.20) org.sonarlint.idea (8.4.0.73538) com.haulmont.jpab (2023.3.1-232) mobi.hsz.idea.gitignore (4.5.1)

Kotlin: 232-1.9.0-IJ8660.185

Best regards, Andreas

brunpoern commented 1 year ago

Just forgot to mention. I also invalidated all IntelliJ and restarted the IDE but the error still occurs.

krasa commented 1 year ago

IntelliJ bug, it will happen without the plugin too, imho.

krasa commented 1 year ago

https://youtrack.jetbrains.com/issue/IDEA-320247/Dead-locks-in-BoundedLocalCache-cause-complete-freezes#focus=Comments-27-7344323.0-0

brunpoern commented 1 year ago

Thanks for the quick response and pointing me to the right issue. Next time I won't trust the IntelliJ dialog so naively ;-)

brunpoern commented 1 year ago

I'm still a bit confused because the mentioned IntelliJ bug should already be fixed in 2023.2. So I guess it's a related but not identical issue and I will create a new bug report for IntelliJ.

Just wanted to double check that also this line in the stacktrace gives a hint that it's an IntelliJ and not a plugin issue, right?

at krasa.formatter.plugin.ProxyCodeStyleManagerDelegator.PLEASE_REPORT_BUGS_TO_JETBRAINS_IF_IT_FAILS_HERE____ORIGINAL
_INTELLIJ_FORMATTER_WAS_USED(ProxyCodeStyleManagerDelegator.java:60)
krasa commented 1 year ago

Right. There is https://youtrack.jetbrains.com/issue/IDEA-320644/Improve-Smart-PSI-pointer-equals-implementation in the comments.

brunpoern commented 1 year ago

Okay, I see. This one is still open. Then this is the one to watch. Thanks again.