On cleanup, only update metadata json if vulnerability data was
actually removed.
@@ -469,9 +469,11 @@ public class MetadataUtility {
var id = idRecord.component1();
var metadata = getPackageVersionMetaData(id, context);
if(metadata.has("vulnerabilities")) {
- metadata.getJSONObject("vulnerabilities").remove(externalVulnerabilityId);
- }
+ var result = metadata.getJSONObject("vulnerabilities").remove(externalVulnerabilityId);
+ if(result != null ) {
updatePackageVersionMetaData(id, metadata, context);
+ }
+ }
});
context.deleteFrom(VulnerabilitiesXPackageVersions.VULNERABILITIES_X_PACKAGE_VERSIONS)
@@ -489,9 +491,11 @@ public class MetadataUtility {
var id = idRecord.component1();
var metadata = getCallableMetaData(id, context);
if(metadata.has("vulnerabilities")) {
- metadata.getJSONObject("vulnerabilities").remove(externalVulnerabilityId);
- }
+ var result = metadata.getJSONObject("vulnerabilities").remove(externalVulnerabilityId);
+ if(result != null) {
updateCallableMetaData(id, metadata, context);
+ }
+ }
});
context.deleteFrom(VulnerabilitiesXCallables.VULNERABILITIES_X_CALLABLES)
