4040 */
4141public class StaleHelper {
4242
43+ /**
44+ * Compute the encoding of the stale javadoc
45+ *
46+ * @return the 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+
4357 /**
4458 * Compute the data used to detect a stale javadoc
4559 *
@@ -55,18 +69,10 @@ public static List<String> getStaleData(Commandline cmd) throws MavenReportExcep
5569 String [] args = cmd .getArguments ();
5670 Collections .addAll (options , args );
5771
58- final Charset cs ;
59- if (JavaVersion .JAVA_SPECIFICATION_VERSION .isAtLeast ("9" )
60- && JavaVersion .JAVA_SPECIFICATION_VERSION .isBefore ("12" )) {
61- cs = StandardCharsets .UTF_8 ;
62- } else {
63- cs = Charset .defaultCharset ();
64- }
65-
6672 for (String arg : args ) {
6773 if (arg .startsWith ("@" )) {
6874 String name = arg .substring (1 );
69- options .addAll (Files .readAllLines (dir .resolve (name ), cs ));
75+ options .addAll (Files .readAllLines (dir .resolve (name ), getDataCharset () ));
7076 ignored .add (name );
7177 }
7278 }
@@ -117,7 +123,7 @@ public static void writeStaleData(Commandline cmd, Path path) throws MavenReport
117123 try {
118124 List <String > curdata = getStaleData (cmd );
119125 Files .createDirectories (path .getParent ());
120- Files .write (path , curdata , StandardCharsets . UTF_8 );
126+ Files .write (path , curdata , getDataCharset () );
121127 } catch (IOException e ) {
122128 throw new MavenReportException ("Error checking stale data" , e );
123129 }
0 commit comments