NullPointerException when Showing DialogWrapper during Gradle buildSearchableOptions

Answered

I am getting a NullPointerException when trying to build my plugin during the gradle task buildSearchableOptions. The line causing it is the .show() call. Below is my main method and my very simple DialogWrapper classes. What am I doing wrong?

ErrorDialog errorDialog = new ErrorDialog(project);

errorDialog.show();
public class ErrorDialog extends DialogWrapper {

   private JPanel mainPanel;
   private JTextArea messageArea;
   private JLabel descriptionLabel;

   public SettingsErrorDialog(@Nullable Project project) {
       super(project);
       setTitle(title);
       init();
   }

   @Nullable
   @Override
   protected JComponent createCenterPanel() {
       return this.popupMainPanel;
   }
}
0
5 comments

Here is the full NullPointerException that I get even when I use the sample DialogWrapper class from: https://www.jetbrains.org/intellij/sdk/docs/user_interface_components/dialog_wrapper.html

java.lang.NullPointerException
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:430)
at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1682)
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1631)
at com.verimatrix.asplugin.settings.SettingsConfigurable.showErrorPopup(SettingsConfigurable.java:385)
at com.verimatrix.asplugin.settings.SettingsConfigurable.setContentFromProjectConfig(SettingsConfigurable.java:357)
at com.verimatrix.asplugin.settings.SettingsConfigurable.createComponent(SettingsConfigurable.java:58)
at com.intellij.openapi.options.ex.ConfigurableWrapper.createComponent(ConfigurableWrapper.java:155)
at com.intellij.ide.ui.search.SearchUtil.processConfigurables(SearchUtil.java:73)
at com.intellij.ide.ui.search.SearchUtil.processProjectConfigurables(SearchUtil.java:46)
at com.intellij.ide.ui.search.TraverseUIStarter.startup(TraverseUIStarter.java:103)
at com.intellij.ide.ui.search.TraverseUIStarter.main(TraverseUIStarter.java:87)
at com.intellij.idea.IdeaApplication.lambda$run$1(IdeaApplication.java:211)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:211)
at com.intellij.idea.IdeaApplication.lambda$initApplication$0(IdeaApplication.java:74)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:347)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
0

I have surrounded the .show() line with a try catch which solves the problem, but this doesn't seem quite right.

0

Please link your full sources

0

I'm having the same problem, NPE in buildSearchableOptions, when I use ideaVersion = IC-2019.2 in my gradle.properties. Downgrading to IC-2018.3.5 solves the problem. All I did was I added the code style settings provider to my language plugin and just to get started I just copy&paste the code from Json plugin. Here's the relevant piece of code:

@NotNull
public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings settings, @NotNull CodeStyleSettings modelSettings) {
return new CodeStyleAbstractConfigurable(settings, modelSettings, this.getConfigurableDisplayName()) {
@Override
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
final Language language = DataSonnetLanguage.INSTANCE;
final CodeStyleSettings currentSettings = getCurrentSettings();
return new TabbedLanguageCodeStylePanel(language, currentSettings, settings) {
@Override
protected void initTabs(CodeStyleSettings settings) {
addIndentOptionsTab(settings);
addSpacesTab(settings);//THIS IS WHERE IT FAILS WITH NPE
addBlankLinesTab(settings);
addWrappingAndBracesTab(settings);
}
};
}
};
}

And the stack trace is:

Searchable options index builder failed
java.lang.NullPointerException
at com.intellij.application.options.CodeStyleAbstractPanel.installPreviewPanel(CodeStyleAbstractPanel.java:437)
at com.intellij.application.options.codeStyle.OptionTreeWithPreviewPanel.init(OptionTreeWithPreviewPanel.java:79)
at com.intellij.application.options.codeStyle.CodeStyleSpacesPanel.<init>(CodeStyleSpacesPanel.java:29)
at com.intellij.application.options.TabbedLanguageCodeStylePanel$MySpacesPanel.<init>(TabbedLanguageCodeStylePanel.java:360)
at com.intellij.application.options.TabbedLanguageCodeStylePanel.addSpacesTab(TabbedLanguageCodeStylePanel.java:95)
at com.foo.bar.language.formatter.SimpleCodeStyleSettingsProvider$1$1.initTabs(SimpleCodeStyleSettingsProvider.java:29)
at com.intellij.application.options.TabbedLanguageCodeStylePanel.ensureTabs(TabbedLanguageCodeStylePanel.java:121)
at com.intellij.application.options.TabbedLanguageCodeStylePanel.getPreviewText(TabbedLanguageCodeStylePanel.java:199)
at com.intellij.application.options.CodeStyleAbstractPanel.createEditor(CodeStyleAbstractPanel.java:138)
at com.intellij.application.options.CodeStyleAbstractPanel.<init>(CodeStyleAbstractPanel.java:97)
at com.intellij.application.options.TabbedLanguageCodeStylePanel.<init>(TabbedLanguageCodeStylePanel.java:54)
at com.foo.bar.language.formatter.SimpleCodeStyleSettingsProvider$1$1.<init>(SimpleCodeStyleSettingsProvider.java:25)
at com.foo.bar.language.formatter.SimpleCodeStyleSettingsProvider$1.createPanel(SimpleCodeStyleSettingsProvider.java:25)
at com.intellij.application.options.CodeStyleAbstractConfigurable.createComponent(CodeStyleAbstractConfigurable.java:34)
at com.intellij.application.options.codeStyle.NewCodeStyleSettingsPanel.<init>(NewCodeStyleSettingsPanel.java:35)
at com.intellij.ConfigurableFactory$createCodeStyleConfigurable$codeStyleConfigurableWrapper$1.createPanel(ConfigurableFactory.kt:46)
at com.intellij.application.options.codeStyle.CodeStyleMainPanel.ensurePanel(CodeStyleMainPanel.java:238)
at com.intellij.application.options.codeStyle.CodeStyleMainPanel.ensureCurrentPanel(CodeStyleMainPanel.java:223)
at com.intellij.application.options.codeStyle.CodeStyleMainPanel.lambda$onCurrentSchemeChanged$0(CodeStyleMainPanel.java:163)
at com.intellij.application.options.codeStyle.CodeStyleMainPanel.onCurrentSchemeChanged(CodeStyleMainPanel.java:170)
at com.intellij.application.options.codeStyle.CodeStyleMainPanel.<init>(CodeStyleMainPanel.java:134)
at com.intellij.application.options.CodeStyleConfigurableWrapper.createComponent(CodeStyleConfigurableWrapper.java:48)
at com.intellij.ide.ui.search.SearchUtil.processConfigurables(SearchUtil.java:76)
at com.intellij.ide.ui.search.SearchUtil.processProjectConfigurables(SearchUtil.java:48)
at com.intellij.ide.ui.search.TraverseUIStarter.startup(TraverseUIStarter.java:106)
at com.intellij.ide.ui.search.TraverseUIStarter.main(TraverseUIStarter.java:87)
at com.intellij.idea.IdeaApplication.lambda$null$3(IdeaApplication.java:154)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:192)
at com.intellij.idea.IdeaApplication.lambda$executeInitAppInEdt$5(IdeaApplication.java:154)
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.dispatchEvent(IdeEventQueue.java:433)
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)

0

Eugene Berman, sorry for delay. I found similar sounding issues here https://github.com/JetBrains/gradle-intellij-plugin/issues/424 and maybe https://github.com/JetBrains/gradle-intellij-plugin/issues/437. Please make sure you use latest available version of gradle-intellij-plugin. If it still reproduces, please file issue and attach your build.gradle for reproducing, thanks.

0

Please sign in to leave a comment.