Skip to content

Commit

Permalink
fix: improve memory usage on NVD update (#6321)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Romero <marcos.romero@mercadoderecebiveis.com.br>
  • Loading branch information
markitovtr1 authored Dec 18, 2023
1 parent 8c6a97b commit 667fde1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public CveApiJson20CveItemSource(File jsonFile) throws IOException {
mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
inputStream = jsonFile.getName().endsWith(".gz") ?
new GZIPInputStream(new BufferedInputStream(Files.newInputStream(jsonFile.toPath()))) :
new BufferedInputStream(new GZIPInputStream(Files.newInputStream(jsonFile.toPath()))) :
new BufferedInputStream(Files.newInputStream(jsonFile.toPath()));
jsonParser = mapper.getFactory().createParser(inputStream);

JsonToken token = null;
do {
token = jsonParser.nextToken();
if (token == JsonToken.FIELD_NAME) {
if (token == JsonToken.FIELD_NAME) {
String fieldName = jsonParser.getCurrentName();
if (fieldName.equals("vulnerabilities") && (jsonParser.nextToken() == JsonToken.START_ARRAY)) {
nextItem = readItem(jsonParser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public JsonArrayCveItemSource(File jsonFile) throws IOException {
mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
inputStream = jsonFile.getName().endsWith(".gz") ?
new GZIPInputStream(new BufferedInputStream(Files.newInputStream(jsonFile.toPath()))) :
new BufferedInputStream(new GZIPInputStream(Files.newInputStream(jsonFile.toPath()))) :
new BufferedInputStream(Files.newInputStream(jsonFile.toPath()));
jsonParser = mapper.getFactory().createParser(inputStream);

Expand Down

0 comments on commit 667fde1

Please sign in to comment.