slachiewicz opened a new pull request, #427:
URL: https://github.com/apache/maven-shared-utils/pull/427

   Deprecates the `StringUtils.replace` and `contains` overloads that `String` 
has had an equivalent for since Java 5. Their only remaining value is 
tolerating `null`.
   
   Fixes [#362](https://github.com/apache/maven-shared-utils/issues/362).
   
   Marked:
   
   - `replace(String, char, char)` -> `String.replace(char, char)`
   - `replace(String, String, String)` -> `String.replace(CharSequence, 
CharSequence)`
   - `contains(String, String)` -> `String.contains(CharSequence)`
   - `contains(String, char)` -> `String.indexOf(int) >= 0`
   
   Left alone: `replace(..., int max)` in both forms, and `replaceOnce`. 
`String.replace` cannot limit the number of replacements, so there is nothing 
to point those at.
   
   The issue lists three methods; `contains(String, char)` is the fourth here. 
Deprecating one `contains` overload and not the other would read as an 
oversight, and its replacement is just as direct. Say the word if you would 
rather it stayed.
   
   Two caveats are written into the javadoc rather than left for callers to 
discover, because neither replacement is a blind swap:
   
   - the JDK methods throw `NullPointerException` where these return `null` or 
`false`
   - `"abc".replace("", "-")` returns `-a-b-c-`, while 
`StringUtils.replace("abc", "", "-")` returns `"abc"` unchanged
   
   `interpolate()` now calls the 4-arg `replace` so the class does not warn 
against itself. That is a delegation change only -- the 3-arg form is 
`replace(text, repl, with, -1)`.
   
   Verified: `mvn -B verify` on JDK 17 -> Tests run: 788, Failures: 0, Errors: 
0. Spotless clean, no deprecation warnings in the build.
   
   *This change was created with AI assistance.*
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to