Skip to content

NPE opening Properties on a non-IResource selection "Cucumber" & "Java Backend" property pages have no enablement filter #671

Description

@alef75

👓 What did you see?

Summary

The Cucumber (io.cucumber.eclipse.editor) and Java Backend (io.cucumber.eclipse.java)
property pages are contributed to org.eclipse.ui.propertyPages without any objectClass
/ adaptable / enabledWhen filter
. As a result they are shown in the Properties dialog of
every selectable element, including objects that are not (and do not adapt to) IResource.
When such an element is selected, the page code calls IResource#getProject() on a null
resource and throws a NullPointerException, which breaks the whole Properties dialog.

Actual behavior

The "Cucumber" and "Java Backend" pages appear in the Properties dialog for that element, and
a NullPointerException is logged; the page (and effectively the dialog) fails to render.
The same NPE also fires from performOk if the page was the last-selected one.

io.cucumber.eclipse.editor:
java.lang.NullPointerException: Cannot invoke
"org.eclipse.core.resources.IResource.getProject()" because "resource" is null
at io.cucumber.eclipse.editor.properties.CucumberEditorProperties.getNode(CucumberEditorProperties.java:111)
at io.cucumber.eclipse.editor.properties.CucumberPropertiesPage.createContents(CucumberPropertiesPage.java:47)
at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:244)
...
at org.eclipse.ui.internal.dialogs.PropertyDialog.createDialogOn(PropertyDialog.java:84)
at org.eclipse.ui.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:152)
(also: CucumberPropertiesPage.performOk(CucumberPropertiesPage.java:108))

io.cucumber.eclipse.java:
java.lang.NullPointerException: Cannot invoke
"org.eclipse.core.resources.IResource.getProject()" because "resource" is null
at io.cucumber.eclipse.java.properties.CucumberJavaBackendProperties.getNode(CucumberJavaBackendProperties.java:198)
at io.cucumber.eclipse.java.properties.JavaBackendPropertyPage.addValidationOption(JavaBackendPropertyPage.java:65)
at io.cucumber.eclipse.java.properties.JavaBackendPropertyPage.createContents(JavaBackendPropertyPage.java:58)

Root cause

The contributions in plugin.xml have no enablement:

io.cucumber.eclipse.editor/plugin.xml

<extension point="org.eclipse.ui.propertyPages">
   <page
         class="io.cucumber.eclipse.editor.properties.CucumberPropertiesPage"
         icon="icons/cukes.gif"
         id="cucumber.eclipse.editor.properties.main"
         name="Cucumber">
   </page>
</extension>

io.cucumber.eclipse.java/plugin.xml
<extension point="org.eclipse.ui.propertyPages">
   <page
         category="cucumber.eclipse.editor.properties.main"
         class="io.cucumber.eclipse.java.properties.JavaBackendPropertyPage"
         id="cucumber.eclipse.backends.java.properties.samplePropertyPage"
         name="Java Backend">
   </page>
</extension>

Proposed fix

Add an enablement so each page is restricted to IResource (covers adaptable selections too):
<page ... >
   <enabledWhen>
      <adapt type="org.eclipse.core.resources.IResource"/>
   </enabledWhen>
</page>
and/or make CucumberEditorProperties#getNode / CucumberJavaBackendProperties#getNode
null-safe (return early / show a "not applicable" message) when no IResource is present.

Workaround

Adding the <enabledWhen><adapt type="org.eclipse.core.resources.IResource"/></enabledWhen>
block to both plugin.xml files (then restarting Eclipse with -clean) fully resolves the
problem without affecting .feature/project usage.


### ✅ What did you expect to see?

## Expected behavior
The Cucumber property pages should only be offered for elements that are (or adapt to)
`IResource`. They should never appear for unrelated objects, and must not throw when no
resource is available.

### 📦 Which tool/library version are you using?

## Environment
- Cucumber Eclipse plugin: **3.0.0.202606031037**
  (io.cucumber.eclipse.editor + io.cucumber.eclipse.java)
- Eclipse: 4.39.0 (build 4.39.0.20260305-0817), Eclipse IDE for C/C++ Developers
- JRE: 21.0.11 (Eclipse Temurin)
- OS: Linux x86_64, GTK

### 🔬 How could we reproduce it?

## Steps to reproduce
1. Install the Cucumber Eclipse plugin.
2. Select any element that is **not** an `IResource` and does not adapt to one — e.g. a
   **Remote System Explorer (RSE) connection** in the "Remote Systems" view (a working set,
   as in #423, reproduces it too).
3. Right-click → **Properties**.

### 📚 Any additional context?

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions