Skip to content

Commit 6573a98

Browse files
committed
Fix bug by using UTF-8 unconditionally
1 parent 51e3c59 commit 6573a98

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import java.io.File;
2222
import java.io.IOException;
23-
import java.nio.charset.Charset;
2423
import java.nio.charset.StandardCharsets;
2524
import java.nio.file.DirectoryStream;
2625
import java.nio.file.Files;
@@ -31,7 +30,6 @@
3130
import java.util.List;
3231

3332
import org.apache.maven.reporting.MavenReportException;
34-
import org.codehaus.plexus.languages.java.version.JavaVersion;
3533
import org.codehaus.plexus.util.cli.Commandline;
3634

3735
/**
@@ -41,21 +39,7 @@
4139
public class StaleHelper {
4240

4341
/**
44-
* Compute the encoding of the stale javadoc
45-
*
46-
* @return the encoding of the stale data
47-
*/
48-
private static Charset getDataCharset() {
49-
if (JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast("9")
50-
&& JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("12")) {
51-
return StandardCharsets.UTF_8;
52-
} else {
53-
return Charset.defaultCharset();
54-
}
55-
}
56-
57-
/**
58-
* Compute the data used to detect a stale javadoc
42+
* Compute the data used to detect a stale javadoc.
5943
*
6044
* @param cmd the command line
6145
* @return the stale data
@@ -72,7 +56,7 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
7256
for (String arg : args) {
7357
if (arg.startsWith("@")) {
7458
String name = arg.substring(1);
75-
options.addAll(Files.readAllLines(dir.resolve(name), getDataCharset()));
59+
options.addAll(Files.readAllLines(dir.resolve(name), StandardCharsets.UTF_8));
7660
ignored.add(name);
7761
}
7862
}
@@ -113,17 +97,17 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
11397
}
11498

11599
/**
116-
* Write the data used to detect a stale javadoc
100+
* Write the data used to detect a stale javadoc.
117101
*
118102
* @param cmd the command line
119103
* @param path the stale data path
120104
* @throws MavenReportException if an error occurs
121105
*/
122106
public static void writeStaleData(Commandline cmd, Path path) throws MavenReportException {
123107
try {
124-
List<String> curdata = getStaleData(cmd);
108+
List<String> currentData = getStaleData(cmd);
125109
Files.createDirectories(path.getParent());
126-
Files.write(path, curdata, getDataCharset());
110+
Files.write(path, currentData, StandardCharsets.UTF_8);
127111
} catch (IOException e) {
128112
throw new MavenReportException("Error checking stale data", e);
129113
}

0 commit comments

Comments
 (0)