Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR revises
FeatureAdapter#getTypes(...)so it doesn't throwNullPointerExceptionwhen deriving the type of aFeaturewhosetypingFeatures()result contains anullentry.Background
The implementation of
Feature::typingFeaturesincludes the last chaining feature when the feature has an ownedFeatureChaining. InFeature_typingFeatures_InvocationDelegate:However,
FeatureChaining::getChainingFeatureis 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 thatFeatureAdapter::getTypesassumes every entry is non-null and recursively processes it as a realFeature.Change
Update
FeatureAdaper::getTypesto check for null as it iterates over typingFeatures.