|
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 nu.studer.java.util.OrderedProperties; |
23 | 24 | import org.sonatype.plexus.build.incremental.BuildContext; |
|
33 | 34 | import java.util.Properties; |
34 | 35 |
|
35 | 36 | public class PropertiesFileGenerator { |
| 37 | + private static final ObjectMapper MAPPER = new ObjectMapper().enable(MapperFeature.BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES); |
36 | 38 |
|
37 | 39 | private LoggerBridge log; |
38 | 40 | private BuildContext buildContext; |
@@ -95,8 +97,7 @@ public void maybeGeneratePropertiesFile(@Nonnull Properties localProperties, Fil |
95 | 97 | if (isJsonFormat) { |
96 | 98 | try (Writer outputWriter = new OutputStreamWriter(outputStream, sourceCharset)) { |
97 | 99 | log.info("Writing json file to [{}] (for module {})...", gitPropsFile.getAbsolutePath(), projectName); |
98 | | - ObjectMapper mapper = new ObjectMapper(); |
99 | | - mapper.writerWithDefaultPrettyPrinter().writeValue(outputWriter, sortedLocalProperties); |
| 100 | + MAPPER.writerWithDefaultPrettyPrinter().writeValue(outputWriter, sortedLocalProperties); |
100 | 101 | } |
101 | 102 | } else { |
102 | 103 | log.info("Writing properties file to [{}] (for module {})...", gitPropsFile.getAbsolutePath(), projectName); |
@@ -135,11 +136,10 @@ private Properties readJsonProperties(@Nonnull File jsonFile, Charset sourceChar |
135 | 136 |
|
136 | 137 | try (final FileInputStream fis = new FileInputStream(jsonFile)) { |
137 | 138 | try (final InputStreamReader reader = new InputStreamReader(fis, sourceCharset)) { |
138 | | - final ObjectMapper mapper = new ObjectMapper(); |
139 | 139 | final TypeReference<HashMap<String, Object>> mapTypeRef = |
140 | 140 | new TypeReference<HashMap<String, Object>>() {}; |
141 | 141 |
|
142 | | - propertiesMap = mapper.readValue(reader, mapTypeRef); |
| 142 | + propertiesMap = MAPPER.readValue(reader, mapTypeRef); |
143 | 143 | } |
144 | 144 | } catch (final Exception ex) { |
145 | 145 | throw new CannotReadFileException(ex); |
|
0 commit comments