Skip to content

Commit 26549aa

Browse files
committed
Fix NPE in CompatibilityUpgrader
This happens when there is an anonomous element referenced in a package relationship. Note that this should not happen in a valid SPDX documents since all elements must have SPDXRef- ID's which will generate a URI reference. Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
1 parent c8dd9dd commit 26549aa

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/main/java/org/spdx/spdxRdfStore/CompatibilityUpgrader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static void upgradeHasFiles(Model model, String documentNamespace) {
132132
Resource existingRelationship = stmt.getObject().asResource();
133133
Resource relatedElement = existingRelationship.getPropertyResourceValue(model.createProperty(SpdxConstants.SPDX_NAMESPACE + SpdxConstants.PROP_RELATED_SPDX_ELEMENT));
134134
Resource relationshipType = existingRelationship.getPropertyResourceValue(model.createProperty(SpdxConstants.SPDX_NAMESPACE + SpdxConstants.PROP_RELATIONSHIP_TYPE));
135-
if (relatedElement.getURI().equals(file.getURI()) &&
135+
if (relatedElement.isURIResource() && relatedElement.getURI().equals(file.getURI()) &&
136136
relationshipType.getURI().equals(RelationshipType.CONTAINS.getIndividualURI())) {
137137
foundContainsRelationships.add(stmt);
138138
}

0 commit comments

Comments
 (0)