Skip to content

ST6RI-951 NullPointerException in FeatureAdapter#getTypes when a feature chain is partially unresolved - #798

Merged
seidewitz merged 2 commits into
masterfrom
ST6RI-951
Sep 8, 2026
Merged

seidewitz merged 2 commits into
masterfrom
ST6RI-951

Conversation

@adaussy

@adaussy adaussy commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

This PR revises FeatureAdapter#getTypes(...) so it doesn't throw NullPointerException when deriving the type of a Feature whose typingFeatures() result contains a null entry.

Background

The implementation of Feature::typingFeatures includes the last chaining feature when the feature has an owned FeatureChaining. In Feature_typingFeatures_InvocationDelegate:

EList<Feature> chainingFeatures = self.getChainingFeature();
if (!chainingFeatures.isEmpty()) {
    Feature lastChainingFeature = chainingFeatures.get(chainingFeatures.size() - 1);
    if (!typingFeatures.contains(lastChainingFeature)) {
        typingFeatures.add(lastChainingFeature);
    }
}

However, FeatureChaining::getChainingFeature is a reference. During import or before reference resolution completes, that reference can legitimately be unresolved or absent from the in-memory model. In that state, self.getChainingFeature() can contain a null value. That null then becomes part of the typingFeatures() result.

The problem is not that typingFeatures() contains null by itself. The problem is that FeatureAdapter::getTypes assumes every entry is non-null and recursively processes it as a real Feature.

Change

Update FeatureAdaper::getTypes to check for null as it iterates over typing Features.

AxelRICHARD and others added 2 commits July 27, 2026 16:16
FeatureAdapter#getTypes(...) can throw a NullPointerException when
deriving the type of a Feature whose typingFeatures() result contains a
null entry.

This can happen for a syntactically valid SysML model during
intermediate model construction, import, or partial linking, when a
FeatureChaining relationship exists but its chainingFeature reference
has not been resolved yet.

The fix is small and defensive: skip null entries returned by
feature.typingFeatures() before recursively calling
FeatureUtil.getTypesOf(...).

Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
@adaussy adaussy added this to the 2026-08 milestone Sep 7, 2026
@seidewitz seidewitz self-assigned this Sep 8, 2026
@seidewitz seidewitz added the bug Something isn't working label Sep 8, 2026
@seidewitz
seidewitz merged commit 87a68c3 into master Sep 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants