Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer Java standard library to Plexus util #1015

Merged
merged 8 commits into from
May 16, 2023
Merged

Prefer Java standard library to Plexus util #1015

merged 8 commits into from
May 16, 2023

Conversation

elharo
Copy link
Contributor

@elharo elharo commented Feb 26, 2023

Begin slog of removing plexus util dependencies we shouldn't have to maintain.

@@ -60,7 +59,7 @@ public void validate(Settings settings, SettingsProblemCollector problems) {
for (int i = 0; i < pluginGroups.size(); i++) {
String pluginGroup = pluginGroups.get(i).trim();

if (StringUtils.isBlank(pluginGroup)) {
if (pluginGroup.trim().isEmpty()) {
addViolation(
problems, Severity.ERROR, "pluginGroups.pluginGroup[" + i + "]", null, "must not be empty");
} else if (!ID_REGEX.matcher(pluginGroup).matches()) {
Copy link
Member

@michael-o michael-o Feb 26, 2023

Choose a reason for hiding this comment

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

This error message is misleading...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I see how, but in any case that would be a pre-existing, unrelated issue. Please file a JIRA on this.

Copy link
Member

Choose a reason for hiding this comment

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

The message says "empty", but test is for blank. We should check wether other spots validate and say then "empty". Those are two different things for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, and they aren't clear to me either. This is a problem with all the isEmpty, isBlank, isNullOrEmpty methods that litter utility libraries across Java, not just here but in Guava and many, many other libraries. They do not agree on what "empty", "blank", and similar terms mean. Sometimes "empty" strings can contain whitespace. Sometimes they can't. Sometimes they can be null. Sometimes they can't. It depends on which version of which library you're using. It's confusing and error prone. That's a big reason I want to get rid of all of them and stick exclusively to JDK methods.

In this case the string was already trimmed in line 60 so empty and blank are the same.

Copy link
Member

Choose a reason for hiding this comment

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

I am included to drop the entire trim. The rest of the class does not trim at all. It should be consistent throughout elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, trim dropped

Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

Looks good.
Just a question: is the goal to remove all references to org.codehaus.plexus.utils.StringUtils because there are lots of them remaining in the code...
Maybe create a JIRA and provide a complete PR for removing all of them ?

@elharo
Copy link
Contributor Author

elharo commented Mar 1, 2023

Yes, I would like to remove all references to org.codehaus.plexus.utils.StringUtils. In fact I would like to remove all references to org.codehaus.plexus.utils and now that you mention it, I would like to get rid of all references to org.codehaus.plexus. Realistically plexus only ever was used in Maven and there's no need for separate projects or repos.

But even sticking to StringUtils that's a long slog across multiple repos, and even in a single repo the semantics of replacement for a call can vary subtly from one invocation to the next so I don't think a single PR is practical.

Copy link
Contributor Author

@elharo elharo left a comment

Choose a reason for hiding this comment

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

Ping. Can I get an approval on this one?

@gnodet gnodet added this to the 4.0.0-alpha-5 milestone Mar 7, 2023
@gnodet gnodet requested a review from michael-o March 7, 2023 22:18
@@ -60,7 +59,7 @@ public void validate(Settings settings, SettingsProblemCollector problems) {
for (int i = 0; i < pluginGroups.size(); i++) {
String pluginGroup = pluginGroups.get(i).trim();

if (StringUtils.isBlank(pluginGroup)) {
if (pluginGroup.trim().isEmpty()) {
addViolation(
problems, Severity.ERROR, "pluginGroups.pluginGroup[" + i + "]", null, "must not be empty");
} else if (!ID_REGEX.matcher(pluginGroup).matches()) {
Copy link
Member

Choose a reason for hiding this comment

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

I am included to drop the entire trim. The rest of the class does not trim at all. It should be consistent throughout elements.

@gnodet gnodet modified the milestones: 4.0.0-alpha-5, 4.0.0-alpha-6 Mar 16, 2023
@gnodet gnodet merged commit 2bbdd97 into master May 16, 2023
@elharo elharo deleted the plexus branch March 1, 2024 18:05
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants