Skip to content

Commit

Permalink
fix(spdx): Avoid serializing the document into a string
Browse files Browse the repository at this point in the history
For large documents this can result in an out of memory error, such as
[1].

Fixes: #8829.

[1]: `UTF16 String size is [..], should be less than 1073741823`

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau authored and sschuberth committed Jul 3, 2024
1 parent 81af6f8 commit 4d49fc2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ class SpdxDocumentReporter : Reporter {
}

return outputFileFormats.map { fileFormat ->
val serializedDocument = fileFormat.mapper.writeValueAsString(spdxDocument)

outputDir.resolve("$REPORT_BASE_FILENAME.${fileFormat.fileExtension}").apply {
bufferedWriter().use { it.write(serializedDocument) }
bufferedWriter().use { writer ->
fileFormat.mapper.writeValue(writer, spdxDocument)
}
}
}
}
Expand Down

0 comments on commit 4d49fc2

Please sign in to comment.