Skip to content

Deprecate StringUtils.concatenate in favor of JDK String.join#361

Merged
elharo merged 6 commits intomasterfrom
concat
Feb 2, 2026
Merged

Deprecate StringUtils.concatenate in favor of JDK String.join#361
elharo merged 6 commits intomasterfrom
concat

Conversation

@elharo
Copy link
Contributor

@elharo elharo commented Feb 1, 2026

fixes #347

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR deprecates the StringUtils.concatenate() method and suggests using Java's built-in String.join() method as a replacement. However, there is a discrepancy between the PR description (which references issue #349 about deprecating StringUtils.clean) and the actual changes (which deprecate StringUtils.concatenate).

Changes:

  • Added @Deprecated annotation to the concatenate(Object... array) method
  • Added @deprecated javadoc tag suggesting String.join() as replacement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

*
* @param array the array of values to concatenate.
* @return the concatenated string.
* @deprecated use <code>java.lang.String.join(</code>) instead
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation message has a malformed HTML code tag. The opening parenthesis is inside the code tag but the closing parenthesis is outside it, making it read as "java.lang.String.join(" followed by ") instead". Based on other deprecation patterns in this file (lines 210, 460, 475, 502, 574, 605), the message should either be:

  • "use {@code java.lang.String.join()}" (using {@code} format without tags)
  • "use java.lang.String.join()" (with both parentheses inside the tag)

The current format with the unmatched parenthesis is inconsistent and will not render correctly in generated documentation.

Copilot uses AI. Check for mistakes.
*
* @param array the array of values to concatenate.
* @return the concatenated string.
* @deprecated use <code>java.lang.String.join(</code>) instead
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggested replacement with String.join() is potentially misleading. The StringUtils.concatenate() method accepts Object[] (varargs) and calls toString() on each element, while String.join() requires CharSequence elements. This means String.join() is not a drop-in replacement for cases where non-CharSequence objects are passed.

Consider clarifying the deprecation message to indicate that elements should be converted to strings first, or suggest using a stream-based approach like: Arrays.stream(array).map(Object::toString).collect(Collectors.joining(""))

This is particularly important since the method signature explicitly accepts Object... array, suggesting it was designed to handle non-string objects.

Copilot uses AI. Check for mistakes.
@apache apache deleted a comment from Copilot AI Feb 1, 2026
@elharo elharo merged commit e950e2c into master Feb 2, 2026
27 checks passed
@elharo elharo deleted the concat branch February 2, 2026 02:04
@github-actions github-actions bot added this to the 3.5.0 milestone Feb 2, 2026
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

@elharo Please assign appropriate label to PR according to the type of change.

@elharo elharo added the deprecated Pull requests that deprecate features label Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated Pull requests that deprecate features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate StringUtils.concatenate

2 participants