JetBrains / intellij-platform-plugin-template

Template repository for creating plugins for IntelliJ Platform
Apache License 2.0
3.14k stars 638 forks source link

Enable Gradle Configuration Cache *.java with *.form constructor NPE #316

Closed LinWanCen closed 1 year ago

LinWanCen commented 1 year ago

https://github.com/JetBrains/intellij-platform-plugin-template/blob/61a1a04ede797d4c3a3a000e63eae3f0123ebfd3/gradle.properties#L29

AuthorWindow.form (Swing UI Designer -> GUI Form) AuthorWindow.java

public class AuthorWindow {
    Project project;
    ToolWindow toolWindow;

    public AuthorWindow(@NotNull Project project, ToolWindow toolWindow) {
        this.project = project;
        this.toolWindow = toolWindow;
        this.input.setText(InputState.getInstance(project).getInput()); // NPE!!!
    }

    JPanel mainPanel;
    JTextArea input;
}

Gradle Version: 7.3.3

Run 1st will create .gradle/configuration-cache Run 2nd will throw:

2022-11-24 03:17:45,481 [   8044]  ERROR - .wm.impl.ToolWindowManagerImpl - Cannot init toolwindow com.github.linwancen.plugin.author.ui.AuthorWindowFactory@105d0dec 
java.lang.NullPointerException
    at com.github.linwancen.plugin.author.ui.AuthorWindow.<init>(AuthorWindow.java:18)
    at com.github.linwancen.plugin.author.ui.AuthorWindowFactory.createToolWindowContent(AuthorWindowFactory.kt:10)
    at com.intellij.openapi.wm.impl.ToolWindowImpl.createContentIfNeeded$intellij_platform_ide_impl(ToolWindowImpl.kt:493)
    at com.intellij.openapi.wm.impl.ToolWindowImpl.scheduleContentInitializationIfNeeded$intellij_platform_ide_impl(ToolWindowImpl.kt:473)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.doShowWindow(ToolWindowManagerImpl.kt:918)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl(ToolWindowManagerImpl.kt:864)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.doRegisterToolWindow(ToolWindowManagerImpl.kt:990)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.initToolWindows(ToolWindowManagerImpl.kt:446)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.access$initToolWindows(ToolWindowManagerImpl.kt:90)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl$beforeProjectOpened$2.run(ToolWindowManagerImpl.kt:427)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:310)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:80)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:128)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:184)
    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:974)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:847)
    at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:739)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
    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)
2022-11-24 03:17:45,484 [   8047]  ERROR - .wm.impl.ToolWindowManagerImpl - IntelliJ IDEA 2020.1  Build #IC-201.6668.121 
2022-11-24 03:17:45,484 [   8047]  ERROR - .wm.impl.ToolWindowManagerImpl - JDK: 11.0.6; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2022-11-24 03:17:45,484 [   8047]  ERROR - .wm.impl.ToolWindowManagerImpl - OS: Windows 10 
2022-11-24 03:17:45,484 [   8047]  ERROR - .wm.impl.ToolWindowManagerImpl - Plugin to blame: Find Author version: 1.00 
2022-11-24 03:17:45,484 [   8047]  ERROR - .wm.impl.ToolWindowManagerImpl - Last Action:  
YannCebron commented 1 year ago

please provide full working sample, it's unclear what InputState is and how exactly AuthorWindow is constructed

YannCebron commented 1 year ago

https://github.com/JetBrains/gradle-intellij-plugin/issues/1283