diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index b3e19123bb..c52a8b8f75 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -23,13 +23,12 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.XMLEvent; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.io.UncheckedIOException; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -142,8 +141,7 @@ public static Model getRawModel(MavenProject project) throws IOException { * @throws IOException if the file is not found or if the file does not parse. */ public static Model getRawModel(File moduleProjectFile) throws IOException { - try (Reader reader = - new BufferedReader(new InputStreamReader(Files.newInputStream(moduleProjectFile.toPath())))) { + try (Reader reader = Files.newBufferedReader(moduleProjectFile.toPath(), Charset.defaultCharset())) { Model result = getRawModel(reader); result.setPomFile(moduleProjectFile); return result; diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java index 64564dfe56..3bd45df37d 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/CoreExtensionUtils.java @@ -16,10 +16,9 @@ * limitations under the License. */ -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.stream.Stream; @@ -52,7 +51,7 @@ public static Stream getCoreExtensions(MavenProject project) throws I return Stream.empty(); } - try (Reader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(extensionsFile)))) { + try (Reader reader = Files.newBufferedReader(extensionsFile, Charset.defaultCharset())) { return new CoreExtensionsXpp3Reader() .read(reader).getExtensions().stream().map(ex -> ExtensionBuilder.newBuilder() .withGroupId(ex.getGroupId())