Skip to content

Commit 26327ee

Browse files
authored
Merge pull request #36 from spdx/typevaluecheck
Check for an existing value in getTypedValue
2 parents 86faccb + f636353 commit 26327ee

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,16 +1286,22 @@ public void delete(String id) throws SpdxInvalidIdException {
12861286
}
12871287

12881288
/**
1289-
* @param id
1289+
* @param id associated with a type
12901290
* @return Type typed value for the ID if it exists and is of an SPDX type, otherwise empty
12911291
* @throws InvalidSPDXAnalysisException
12921292
*/
12931293
public Optional<TypedValue> getTypedValue(String id) throws InvalidSPDXAnalysisException {
12941294
Objects.requireNonNull(id, "Missing required ID");
1295+
if (!exists(id)) {
1296+
return Optional.empty();
1297+
}
12951298
model.enterCriticalSection(false);
12961299
try {
12971300
try {
12981301
Resource idResource = idToResource(id);
1302+
if (!this.model.containsResource(idResource)) {
1303+
return Optional.empty();
1304+
}
12991305
Resource idClass = idToClass(idResource);
13001306
if (Objects.isNull(idClass)) {
13011307
return Optional.empty();

0 commit comments

Comments
 (0)