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

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

commit 6573a9879cd60f125a1daac3d8ff38993642e08d
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Wed Oct 15 11:43:38 2025 -0400

    Fix bug by using UTF-8 unconditionally
---
 .../apache/maven/plugins/javadoc/StaleHelper.java  | 26 +++++-----------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java 
b/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
index 6658a7e2..61f7a102 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java
@@ -20,7 +20,6 @@ package org.apache.maven.plugins.javadoc;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
@@ -31,7 +30,6 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.cli.Commandline;
 
 /**
@@ -41,21 +39,7 @@ import org.codehaus.plexus.util.cli.Commandline;
 public class StaleHelper {
 
     /**
-     * Compute the encoding of the stale javadoc
-     *
-     * @return the encoding of the stale data
-     */
-    private static Charset getDataCharset() {
-        if (JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast("9")
-                && JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("12")) {
-            return StandardCharsets.UTF_8;
-        } else {
-            return Charset.defaultCharset();
-        }
-    }
-
-    /**
-     * Compute the data used to detect a stale javadoc
+     * Compute the data used to detect a stale javadoc.
      *
      * @param cmd the command line
      * @return the stale data
@@ -72,7 +56,7 @@ public class StaleHelper {
             for (String arg : args) {
                 if (arg.startsWith("@")) {
                     String name = arg.substring(1);
-                    options.addAll(Files.readAllLines(dir.resolve(name), 
getDataCharset()));
+                    options.addAll(Files.readAllLines(dir.resolve(name), 
StandardCharsets.UTF_8));
                     ignored.add(name);
                 }
             }
@@ -113,7 +97,7 @@ public class StaleHelper {
     }
 
     /**
-     * Write the data used to detect a stale javadoc
+     * Write the data used to detect a stale javadoc.
      *
      * @param cmd the command line
      * @param path the stale data path
@@ -121,9 +105,9 @@ public class StaleHelper {
      */
     public static void writeStaleData(Commandline cmd, Path path) throws 
MavenReportException {
         try {
-            List<String> curdata = getStaleData(cmd);
+            List<String> currentData = getStaleData(cmd);
             Files.createDirectories(path.getParent());
-            Files.write(path, curdata, getDataCharset());
+            Files.write(path, currentData, StandardCharsets.UTF_8);
         } catch (IOException e) {
             throw new MavenReportException("Error checking stale data", e);
         }

Reply via email to