aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
764 stars 221 forks source link

Exception: Running a security scan after closing the CodeWhisperer Security Issues window causes an exception #3738

Closed KevinDHunter closed 10 months ago

KevinDHunter commented 1 year ago

Describe the bug The plugin assumes that the CodeWhisperer Security Issues window is always present, and crashes if it is not.

If you run a security scan and close (X-out) the CodeWhisperer Security Issues window, then run another scan, you get the following exception.

com.intellij.util.IncorrectOperationException: Sorry but parent: Content name=<html><body>CodeWhisperer Security Issues <font color="#787878"> 4 </font></body></html>; tab name='<html><body>CodeWhisperer Security Issues <font color="#787878"> 4 </font></body></html>'; toolwindow='<html><body>CodeWhisperer Security Issues <font color="#787878"> 4 </font></body></html>' (class com.intellij.ui.content.impl.ContentImpl) has already been disposed (see the cause for stacktrace) so the child: com.intellij.util.SingleAlarm@2e0d9c8b (class com.intellij.util.SingleAlarm) will never be disposed
    at com.intellij.openapi.util.ObjectTree.register(ObjectTree.java:43)
    at com.intellij.openapi.util.Disposer.register(Disposer.java:164)
    at com.intellij.util.Alarm.<init>(Alarm.java:143)
    at com.intellij.util.SingleAlarm.<init>(SingleAlarm.kt:13)
    at com.intellij.util.SingleAlarm.<init>(SingleAlarm.kt:7)
    at com.intellij.util.SingleAlarm.<init>(SingleAlarm.kt)
    at com.intellij.openapi.wm.impl.content.ContentTabLabel.<init>(ContentTabLabel.java:120)
    at com.intellij.openapi.wm.impl.content.TabContentLayout.contentAdded(TabContentLayout.java:400)
    at com.intellij.openapi.wm.impl.content.ToolWindowContentUi$1.contentAdded(ToolWindowContentUi.java:155)
    at jdk.internal.reflect.GeneratedMethodAccessor113.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 com.intellij.util.EventDispatcher.dispatchVoidMethod(EventDispatcher.java:120)
    at com.intellij.util.EventDispatcher.lambda$createMulticaster$1(EventDispatcher.java:85)
    at jdk.proxy2/jdk.proxy2.$Proxy127.contentAdded(Unknown Source)
    at com.intellij.ui.content.impl.ContentManagerImpl.fireContentAdded(ContentManagerImpl.java:611)
    at com.intellij.ui.content.impl.ContentManagerImpl.doAddContent(ContentManagerImpl.java:198)
    at com.intellij.ui.content.impl.ContentManagerImpl.addContent(ContentManagerImpl.java:171)
    at software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager$addCodeScanUI$1.invoke(CodeWhispererCodeScanManager.kt:265)
    at software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager$addCodeScanUI$1.invoke(CodeWhispererCodeScanManager.kt:261)
    at com.intellij.openapi.application.ActionsKt.runInEdt(actions.kt:50)
    at com.intellij.openapi.application.ActionsKt.runInEdt$default(actions.kt:47)
    at software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager.addCodeScanUI(CodeWhispererCodeScanManager.kt:261)
    at software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager.beforeCodeScan(CodeWhispererCodeScanManager.kt:378)
    at software.aws.toolkits.jetbrains.services.codewhisperer.codescan.CodeWhispererCodeScanManager.runCodeScan(CodeWhispererCodeScanManager.kt:140)
    at software.aws.toolkits.jetbrains.services.codewhisperer.explorer.nodes.RunCodeScanNode.onDoubleClick(RunCodeScanNode.kt:23)
    at software.aws.toolkits.jetbrains.core.explorer.devToolsTab.DevToolsToolWindow$2.onDoubleClick(DevToolsToolWindow.kt:65)
    at com.intellij.ui.DoubleClickListener.onClick(DoubleClickListener.java:30)
    at com.intellij.ui.ClickListener$1.mouseReleased(ClickListener.java:58)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6656)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
    at com.intellij.ui.treeStructure.Tree.processMouseEvent(Tree.java:424)
    at java.desktop/java.awt.Component.processEvent(Component.java:6421)
    at java.desktop/java.awt.Container.processEvent(Container.java:2266)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2804)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:790)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:731)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:763)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:761)
    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:760)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:667)
    at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:615)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:570)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:68)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:349)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:348)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:348)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:343)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:995)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:995)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$4(IdeEventQueue.kt:343)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:385)
    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)

To reproduce

  1. Run a security scan.
  2. After the scan completes, click on the little "x" in the CodeWhisperer Security Issues window. (As opposed to minimizing the "Problems" area using the "dash" all the way on the right.) See screen shot below.
  3. Run another scan

You get an "IDE error" message which, when you click for more information, gives you the exception above. The "Stop Security Scan" option is now displayed, but doesn't do anything. You have to exit PyCharm and restart it to get things back to working again.

Expected behavior It should simply re-create the CodeWhisperer Security Issues window as required, not assume that it's already there.

Screenshots This is what I mean by the "x" on the window: image

Here's what it looks like afterwards: image

Your Environment

leigaol commented 11 months ago

Hi @KevinDHunter , this bug has been fixed in the latest AWS Toolkit for JetBrains v2.0+. We included various security scan improvements in this release. Could you try installing the latest build and do security scan? Thank you!