-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I ran into a super dubious lazy-loading issue (supposedly), related to reading filesAnalyzed from a document deserialized from a json file that did not set this property.
I tried to verify that conversion from tag/value to json using the Python tools does not change any properties. To that end, I wrote a simple test in spdx-testbed:
@Test
public void detectDifferences()
throws IOException, InvalidFileNameException, InvalidSPDXAnalysisException {
var convertedFile = SpdxToolsHelper.deserializeDocument(new File("converted.json"));
var originalFile = SpdxToolsHelper.deserializeDocument(new File("SPDXTagExample-v2.2.spdx"));
var differences = Comparisons.findDifferencesInSerializedJson(convertedFile, originalFile);
assertThat(differences).isEmpty();
}
This test failed, because filesAnalyzed was set to true for the document deserialized from tag/value (named originalFile here), while it was unspecified for the document deserialized from json (named convertedFile).
I first suspected that the json reader does not set the default of true while the tag/value reader does.
This may be one issue, but I ran into something weirder: When setting a breakpoint on the var differences = ... line and evaluating the package in question via
convertedFile.getModelStore().getTypedValue(convertedFile.getDocumentUri(), "SPDXRef-Package")
, the filesAnalyzed value actually came back as true, and the test subsequently passed. This feels like some strange lazy-loading issue, but I can't debug anymore because it stopped behaving like this; I can't reproduce this behavior anymore and the test now consistently fails on my machine.
So...
filesAnalyzedshould probably be set totrueas default, like the spec says- I am utterly flabberghasted regarding the lazy loading issue
For completeness sake, this is the json file that I used. It was created by converting the 2.2 tag/value example for spdx-spec to json using the Python tools. I think most of it is irrelevant though, the important part is that it contains a package glibc which does not have a value for filesAnalyzed.
converted.zip