-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Reduced garbage on InsightsReport's serialization
- Loading branch information
Showing
10 changed files
with
90 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* Copyright (C) Red Hat 2023 */ | ||
package com.redhat.insights; | ||
|
||
import com.fasterxml.jackson.core.Version; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
|
||
/** | ||
* Utility class to provide a factory method for ObjectMapper used by {@link | ||
* InsightsReport#serialize} methods | ||
*/ | ||
class ObjectMappers { | ||
|
||
public static ObjectMapper createFor(InsightsReport insightsReport) { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
mapper.registerModule(new JavaTimeModule()); | ||
|
||
SimpleModule simpleModule = | ||
new SimpleModule( | ||
"SimpleModule", new Version(1, 0, 0, null, "com.redhat.insights", "runtimes-java")); | ||
simpleModule.addSerializer(InsightsReport.class, insightsReport.getSerializer()); | ||
for (InsightsSubreport subreport : insightsReport.getSubreports().values()) { | ||
simpleModule.addSerializer(subreport.getClass(), subreport.getSerializer()); | ||
} | ||
mapper.registerModule(simpleModule); | ||
return mapper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters