From 2c18e899358a3c52deb31cd748cd26475f687960 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 13 Aug 2025 05:37:45 -0400 Subject: [PATCH 1/2] Prefer JDK replace method over deprecated StringUtils method --- .../plugins/javadoc/AbstractJavadocMojo.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 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 8a191aef3..1117d6496 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -2663,7 +2663,7 @@ private void populateCompileArtifactMap(Map compileArtifactMap } /** - * Method that sets the bottom text that will be displayed on the bottom of the + * Method that sets the text that will be displayed on the bottom of the * javadocs. * * @return a String that contains the text that will be displayed at the bottom of the javadoc @@ -2678,32 +2678,30 @@ private String getBottomText() { final String currentYear = Integer.toString(localDate.getYear()); - String theBottom = StringUtils.replace(this.bottom, "{currentYear}", currentYear); + String theBottom = this.bottom.replace("{currentYear}", currentYear); if ((inceptionYear == null) || inceptionYear.equals(currentYear)) { - theBottom = StringUtils.replace(theBottom, "{inceptionYear}–", ""); + theBottom = theBottom.replace("{inceptionYear}–", ""); } else { - theBottom = StringUtils.replace(theBottom, "{inceptionYear}", inceptionYear); + theBottom = theBottom.replace("{inceptionYear}", inceptionYear); } if (project.getOrganization() == null) { - theBottom = StringUtils.replace(theBottom, " {organizationName}", ""); + theBottom = theBottom.replace(" {organizationName}", ""); } else { if (StringUtils.isNotEmpty(project.getOrganization().getName())) { if (StringUtils.isNotEmpty(project.getOrganization().getUrl())) { - theBottom = StringUtils.replace( - theBottom, + theBottom = theBottom.replace( "{organizationName}", "" + project.getOrganization().getName() + ""); } else { - theBottom = StringUtils.replace( - theBottom, + theBottom = theBottom.replace( "{organizationName}", project.getOrganization().getName()); } } else { - theBottom = StringUtils.replace(theBottom, " {organizationName}", ""); + theBottom = theBottom.replace(" {organizationName}", ""); } } @@ -4813,7 +4811,7 @@ private void addGroups(List arguments) throws MavenReportException { getLog().warn("A group option is empty. Ignore this option."); } } else { - String groupTitle = StringUtils.replace(group.getTitle(), ",", ","); + String groupTitle = group.getTitle().replace(",", ","); addArgIfNotEmpty( arguments, "-group", From 43f607c671f033cf01914e1fb9fe8b7272727b93 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 13 Aug 2025 05:45:11 -0400 Subject: [PATCH 2/2] check for null --- .../maven/plugins/javadoc/AbstractJavadocMojo.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 1117d6496..192af3f53 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -2663,12 +2663,15 @@ private void populateCompileArtifactMap(Map compileArtifactMap } /** - * Method that sets the text that will be displayed on the bottom of the - * javadocs. + * Method that sets the text that will be displayed on the bottom of the javadocs. * * @return a String that contains the text that will be displayed at the bottom of the javadoc */ private String getBottomText() { + if (this.bottom == null) { + return null; + } + final String inceptionYear = project.getInceptionYear(); // get Reproducible Builds outputTimestamp date value or the current local date. @@ -2697,8 +2700,7 @@ private String getBottomText() { + project.getOrganization().getName() + ""); } else { theBottom = theBottom.replace( - "{organizationName}", - project.getOrganization().getName()); + "{organizationName}", project.getOrganization().getName()); } } else { theBottom = theBottom.replace(" {organizationName}", "");