You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2026/01/07 17:17:42 UTC

(maven-checkstyle-plugin) branch master updated: Let the XML parser detect the encoding (#659)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 990bef3  Let the XML parser detect the encoding (#659)
990bef3 is described below

commit 990bef3be4fc1137c6064a4bfbb539325a1ea283
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Wed Jan 7 17:17:36 2026 +0000

    Let the XML parser detect the encoding (#659)
    
    * wip
    
    * Remove use of deprecated class
---
 .../maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java    | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
index 2f69842..ce6978f 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
@@ -21,13 +21,12 @@ package org.apache.maven.plugins.checkstyle;
 import javax.inject.Inject;
 import javax.inject.Named;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.Reader;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
@@ -61,7 +60,6 @@ import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.PathTool;
-import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.xml.pull.MXParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -586,9 +584,9 @@ public class CheckstyleViolationCheckMojo extends AbstractMojo {
             return;
         }
 
-        try (Reader reader = new BufferedReader(ReaderFactory.newXmlReader(outputXmlFile))) {
+        try (InputStream in = Files.newInputStream(outputXmlFile.toPath())) {
             XmlPullParser xpp = new MXParser();
-            xpp.setInput(reader);
+            xpp.setInput(in, null); // null tells the parser to detect the encoding
 
             final List<Violation> violationsList = getViolations(xpp);
             long violationCount = countViolations(violationsList);