From 1799d1ac0383e3ec08652822e0771b60a73b2075 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 4 Dec 2024 05:39:49 -0500 Subject: [PATCH] Specify locale for case conversion --- .../plugins/javadoc/AbstractJavadocMojo.java | 4 ++-- .../plugins/javadoc/TestJavadocJarMojo.java | 5 +++-- .../plugins/javadoc/TestJavadocReport.java | 2 +- .../plugins/javadoc/JavadocReportTest.java | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index 635b7aea9..cd75857fa 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -1787,7 +1787,7 @@ protected File getClassesFile(MavenProject project) { * @return the list of source paths for the given project */ protected List getProjectSourceRoots(MavenProject p) { - if ("pom".equals(p.getPackaging().toLowerCase())) { + if ("pom".equals(p.getPackaging().toLowerCase(Locale.ENGLISH))) { return Collections.emptyList(); } @@ -1801,7 +1801,7 @@ protected List getProjectSourceRoots(MavenProject p) { * @return the list of source paths for the execution project of the given project */ protected List getExecutionProjectSourceRoots(MavenProject p) { - if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase())) { + if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) { return Collections.emptyList(); } diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java index 67cb170be..b6d64b4f0 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; @@ -189,7 +190,7 @@ protected List getProjectBuildOutputDirs(MavenProject p) { @Override protected List getProjectSourceRoots(MavenProject p) { - if ("pom".equals(p.getPackaging().toLowerCase())) { + if ("pom".equals(p.getPackaging().toLowerCase(Locale.ENGLISH))) { return Collections.emptyList(); } @@ -198,7 +199,7 @@ protected List getProjectSourceRoots(MavenProject p) { @Override protected List getExecutionProjectSourceRoots(MavenProject p) { - if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase())) { + if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) { return Collections.emptyList(); } diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java index 4c8f900c5..2080e8b5f 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java @@ -214,7 +214,7 @@ protected List getProjectSourceRoots(MavenProject p) { @Override protected List getExecutionProjectSourceRoots(MavenProject p) { - if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase())) { + if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) { return Collections.emptyList(); } diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java index d15875564..79478c463 100644 --- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java +++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java @@ -30,6 +30,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; @@ -427,31 +428,31 @@ public void testCustomConfiguration() throws Exception { // read the contents of the html files based on some of the parameter values // author == false String str = readFile(apidocs.resolve("custom/configuration/AppSample.html")); - assertFalse(str.toLowerCase().contains("author")); + assertFalse(str.toLowerCase(Locale.ENGLISH).contains("author")); // bottom - assertTrue(str.toUpperCase().contains("SAMPLE BOTTOM CONTENT")); + assertTrue(str.toUpperCase(Locale.ENGLISH).contains("SAMPLE BOTTOM CONTENT")); // offlineLinks if (JavaVersion.JAVA_VERSION.isBefore("11.0.2")) { assertThat(str) .containsIgnoringCase("href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/lang/string.html"); } else { - assertTrue(str.toLowerCase() + assertTrue(str.toLowerCase(Locale.ENGLISH) .contains("href=\"http://java.sun.com/j2se/1.4.2/docs/api/java.base/java/lang/string.html")); } // header - assertTrue(str.toUpperCase().contains("MAVEN JAVADOC PLUGIN TEST")); + assertTrue(str.toUpperCase(Locale.ENGLISH).contains("MAVEN JAVADOC PLUGIN TEST")); // footer if (JavaVersion.JAVA_VERSION.isBefore("16-ea") && !System.getProperty("java.vm.name").contains("OpenJ9")) { - assertTrue(str.toUpperCase().contains("MAVEN JAVADOC PLUGIN TEST FOOTER")); + assertTrue(str.toUpperCase(Locale.ENGLISH).contains("MAVEN JAVADOC PLUGIN TEST FOOTER")); } // nohelp == true - assertFalse(str.toUpperCase().contains("/HELP-DOC.HTML")); + assertFalse(str.toUpperCase(Locale.ENGLISH).contains("/HELP-DOC.HTML")); // check the wildcard (*) package exclusions -- excludePackageNames parameter assertThat(apidocs.resolve("custom/configuration/exclude1/Exclude1App.html")) @@ -798,8 +799,9 @@ public void testTag() throws Exception { // which is not enough for Java 11 anymore if (JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("11")) { assertThat(readed).contains(">Version:" + LINE_SEPARATOR + "
1.0
") - || readed.toLowerCase().contains("" + LINE_SEPARATOR + "
1.0
" /* JDK 8 */)); + assertTrue(readed.toLowerCase(Locale.ENGLISH).contains("" + LINE_SEPARATOR + "
1.0
") + || readed.toLowerCase(Locale.ENGLISH) + .contains("" + LINE_SEPARATOR + "
1.0
" /* JDK 8 */)); } }