ssi-schaefer / lcdsl

Eclipse Launch Configuration DSL (Xtext based)
Eclipse Public License 1.0
23 stars 12 forks source link

NPE with unknown launch types #37

Closed Bananeweizen closed 2 years ago

Bananeweizen commented 3 years ago

Have a stored launch config (.launch, not .lc) in your workspace that is unknown to all the plugins in the current IDE. In that case the launch view is completely unusable because of NPE during creation of the tree. The view needs to filter out all launches where the container cannot be calculated.

java.lang.NullPointerException
    at org.eclipse.debug.ui.launchview.internal.model.LaunchViewModel.lambda$9(LaunchViewModel.java:68)
    at java.base/java.util.TreeMap$KeySpliterator.forEachRemaining(TreeMap.java:2754)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.eclipse.debug.ui.launchview.internal.model.LaunchViewModel.getModel(LaunchViewModel.java:67)
    at org.eclipse.debug.ui.launchview.internal.view.LaunchViewImpl.lambda$7(LaunchViewImpl.java:271)

In our case this happens because we declare own launch config types and have serialized launches for these types in our example and test models. And of course those runtime-only launch types are unknown to the IDE.

mduft commented 3 years ago

Could you come up with a small demo of the problem? If I simply put 2 Java launch configs in a project, open one of them and change it to launchConfiguration type='XXX' nothing bad happens, also if I close and re-open the view, or even restart eclipse...

Bananeweizen commented 3 years ago

I was able to reduce it to a single file only. And you are right, setting arbitrary values does NOT cause the exception. But this file causes the exception:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.epic.perleditor.perlbuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

It is stored as someproject/.externalToolBuilders/org.epic.perleditor.perlbuilder.launch, and I'm not even sure what externalToolBuilders means there. It's not listed in the Builders tab of the project properties, so I'm slightly confused myself. Since this seems to be related to running a Perl builder from the Epic plugin, I can probably also get rid of it completely, as long as there is no fix available.

mduft commented 3 years ago

Strange - I will paste this here and perform some tests :)

mduft commented 3 years ago

If I paste this exact launch configuration in my test workspace, the launch immediately appears in the Launch Configurations View. So I assume that it may have something to do with another plugin installed in your IDE... not really sure which one though.

Edit: Nevertheless I can still guard against the NPE in this case. The launch configuration will silently not be shown in this case as we cannot determine its parent for some reason..

Bananeweizen commented 2 years ago

This seems to have been fixed at some point. At least I can see the null check at the same line in the code that lives at eclipse now.