You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/07/24 12:39:30 UTC
[PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
elharo opened a new pull request, #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157
StringUtils.join(Object[], String) is deprecated. Replaced with the equivalent String.join(String, CharSequence...) from the standard library.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157#discussion_r3838454440
##########
src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java:
##########
@@ -347,6 +348,25 @@ private List<File> findJarfiles() throws MojoExecutionException {
return archives;
}
+ /**
+ * Joins a string array with commas, skipping null elements.
+ *
+ * @param strings the strings to join
+ * @return the comma-separated string, or {@code null} if the input is {@code null}
+ */
+ private static String joinStrings(String[] strings) {
+ if (strings == null) {
+ return null;
+ }
+ StringJoiner joiner = new StringJoiner(",");
Review Comment:
This is unnecessary. includes and excludes might be null but they cannot have null elements and we do not need to check for this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157#issuecomment-5749347608
@elharo Please assign appropriate label to PR according to the type of change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157#discussion_r3645463647
##########
src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java:
##########
@@ -334,8 +334,8 @@ private List<File> findJarfiles() throws MojoExecutionException {
}
if (archiveDirectory != null) {
- String includeList = (includes != null) ? StringUtils.join(includes, ",") : null;
- String excludeList = (excludes != null) ? StringUtils.join(excludes, ",") : null;
+ String includeList = (includes != null) ? String.join(",", includes) : null;
+ String excludeList = (excludes != null) ? String.join(",", excludes) : null;
Review Comment:
`String.join` throws a `NullPointerException` if any element inside `includes`/`excludes` is `null`, whereas `StringUtils.join(Object[], String)` would not (it effectively skips/omits null elements). This is a behavior change that can surface as a runtime failure when users provide plugin configuration with accidental null entries. Consider filtering out nulls before joining (e.g., stream + `filter(Objects::nonNull)` + `Collectors.joining(\",\")`) or normalizing null elements to an empty string prior to calling `String.join`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157#discussion_r3838411288
##########
src/main/java/org/apache/maven/plugins/jarsigner/AbstractJarsignerMojo.java:
##########
@@ -334,8 +336,12 @@ private List<File> findJarfiles() throws MojoExecutionException {
}
if (archiveDirectory != null) {
- String includeList = (includes != null) ? StringUtils.join(includes, ",") : null;
- String excludeList = (excludes != null) ? StringUtils.join(excludes, ",") : null;
+ String includeList = (includes != null)
+ ? Arrays.stream(includes).filter(Objects::nonNull).collect(Collectors.joining(","))
Review Comment:
This is vastly too complex. Redo without lambdas or ternary operators.
##########
src/test/java/org/apache/maven/plugins/jarsigner/JarsignerVerifyMojoTest.java:
##########
@@ -166,4 +167,24 @@ public void testErrorWhenNotSignedOnNonExistingSigning() throws Exception {
mojoException.getMessage(),
containsString(mainArtifact.getFile().getPath()));
}
+
+ /** Includes with null elements should not cause NPE in String.join replacement */
Review Comment:
delete "https://github.com/apache/maven-jarsigner/issues/47" and add period at end
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157#discussion_r3838413840
##########
src/test/java/org/apache/maven/plugins/jarsigner/JarsignerVerifyMojoTest.java:
##########
@@ -166,4 +167,24 @@ public void testErrorWhenNotSignedOnNonExistingSigning() throws Exception {
mojoException.getMessage(),
containsString(mainArtifact.getFile().getPath()));
}
+
+ /** Includes with null elements should not cause NPE in String.join replacement */
+ @Test
+ public void testIncludesWithNullElement() throws Exception {
+ Artifact mainArtifact = TestArtifacts.createJarArtifact(dummyMavenProjectDir, "my-project.jar");
+ when(project.getArtifact()).thenReturn(mainArtifact);
+ when(jarSigner.execute(any(JarSignerVerifyRequest.class))).thenReturn(RESULT_OK);
+ configuration.put("archiveDirectory", dummyMavenProjectDir.getPath());
+ configuration.put("processMainArtifact", "false");
+
+ JarsignerVerifyMojo mojo = mojoTestCreator.configure(configuration);
+
+ Field includesField = AbstractJarsignerMojo.class.getDeclaredField("includes");
+ includesField.setAccessible(true);
Review Comment:
do not use setAccessible or reflection. Test only via public API and integration tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace deprecated StringUtils.join with String.join [maven-jarsigner-plugin]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo merged PR #157:
URL: https://github.com/apache/maven-jarsigner-plugin/pull/157
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org