|
18 | 18 | package pl.project13.core; |
19 | 19 |
|
20 | 20 | import com.fasterxml.jackson.core.type.TypeReference; |
| 21 | +import com.fasterxml.jackson.databind.MapperFeature; |
21 | 22 | import com.fasterxml.jackson.databind.ObjectMapper; |
22 | 23 | import org.sonatype.plexus.build.incremental.BuildContext; |
23 | 24 | import pl.project13.core.log.LoggerBridge; |
|
32 | 33 | import java.util.Properties; |
33 | 34 |
|
34 | 35 | public class PropertiesFileGenerator { |
| 36 | + private static final ObjectMapper MAPPER = new ObjectMapper().enable(MapperFeature.BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES); |
35 | 37 |
|
36 | 38 | private LoggerBridge log; |
37 | 39 | private BuildContext buildContext; |
@@ -91,8 +93,7 @@ public void maybeGeneratePropertiesFile(@Nonnull Properties localProperties, Fil |
91 | 93 | if (isJsonFormat) { |
92 | 94 | try (Writer outputWriter = new OutputStreamWriter(outputStream, sourceCharset)) { |
93 | 95 | log.info("Writing json file to [{}] (for module {})...", gitPropsFile.getAbsolutePath(), projectName); |
94 | | - ObjectMapper mapper = new ObjectMapper(); |
95 | | - mapper.writerWithDefaultPrettyPrinter().writeValue(outputWriter, sortedLocalProperties); |
| 96 | + MAPPER.writerWithDefaultPrettyPrinter().writeValue(outputWriter, sortedLocalProperties); |
96 | 97 | } |
97 | 98 | } else { |
98 | 99 | log.info("Writing properties file to [{}] (for module {})...", gitPropsFile.getAbsolutePath(), projectName); |
@@ -131,11 +132,10 @@ private Properties readJsonProperties(@Nonnull File jsonFile, Charset sourceChar |
131 | 132 |
|
132 | 133 | try (final FileInputStream fis = new FileInputStream(jsonFile)) { |
133 | 134 | try (final InputStreamReader reader = new InputStreamReader(fis, sourceCharset)) { |
134 | | - final ObjectMapper mapper = new ObjectMapper(); |
135 | 135 | final TypeReference<HashMap<String, Object>> mapTypeRef = |
136 | 136 | new TypeReference<HashMap<String, Object>>() {}; |
137 | 137 |
|
138 | | - propertiesMap = mapper.readValue(reader, mapTypeRef); |
| 138 | + propertiesMap = MAPPER.readValue(reader, mapTypeRef); |
139 | 139 | } |
140 | 140 | } catch (final Exception ex) { |
141 | 141 | throw new CannotReadFileException(ex); |
|
0 commit comments