GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — prefer JDK String replace methods to Plexus ones by elharo · Pull Request #193 · apache/maven-release

Conversation

@elharo

@elharo elharo commented May 31, 2023

Copy link
Copy Markdown
Contributor

@timtebeek

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@elharo
prefer JDK methods to Plexus ones
d1714ab
@elharo
elharo requested a review from slachiewicz May 31, 2023 11:17
@elharo elharo changed the title prefer JDK methods to Plexus ones prefer JDK replace methods to Plexus ones May 31, 2023
@elharo elharo changed the title prefer JDK replace methods to Plexus ones prefer JDK String replace methods to Plexus ones May 31, 2023
@slachiewicz

slachiewicz commented May 31, 2023

Copy link
Copy Markdown
Member

Is this null safe?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@elharo

elharo commented May 31, 2023

Copy link
Copy Markdown
Contributor Author

Yes. None of the strings involved can be null here. They're either literals or null-checked earlier in the method.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

slachiewicz
slachiewicz approved these changes May 31, 2023
View reviewed changes
@elharo
elharo merged commit f744036 into master May 31, 2023
@elharo
elharo deleted the string branch May 31, 2023 14:09
@timtebeek

timtebeek commented May 31, 2023

Copy link
Copy Markdown
Contributor

@timtebeek

Appreciate the update @elharo ; do I understand that this is one you'd like to tackle next?
I had a quick look; there's some 190 occurrences of StringUtils.replace(..) left in Apache Maven;
45 of those are in src/test; most involve replacing some variant of slashes:
https://public.moderne.io/results/kTDTf/data-tables (temporary link) / Google Sheets (less temporary)

Since we can't yet detect nullability, we'd likely have to insert a null check and fallback, which might look slightly awkward in some. Potentially we'd be able to clean that up in the future, but that would be some time away. Let me know if this is something you'd want to proceed with.

Alternatively there's another few common methods that can be found through:
https://public.moderne.io/recipes/org.openrewrite.java.search.FindMethods
With method pattern *..StringUtils *(..) run against the Apache Maven organization (top right dropdown).
Or we can have a look at some of the FileUtils/IOUtils, although I suspect those would require Java 11+ for JDK replacements.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@elharo

elharo commented May 31, 2023

Copy link
Copy Markdown
Contributor Author

Not necessarily next. Just thought I'd call your attention to some methods that are really, really out of date

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@elharo

elharo commented May 31, 2023

Copy link
Copy Markdown
Contributor Author

A lot of FileUtils and IOUtils can be fixed in Java 8. I'm not sure it's a simple search and replace though. For instance, I've removed a lot of IOUtils.close() methods by using try with resources.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski slawekjaranowski added the maintenance label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@slachiewicz slachiewicz slachiewicz approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

maintenance

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@elharo @slachiewicz @timtebeek @slawekjaranowski
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.