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

[MNG-8146] Drop commons-lang #1564

Merged
merged 3 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ private static boolean isDigits(String str) {
return false;
}
for (int i = 0; i < str.length(); i++) {
if (!Character.isDigit(str.charAt(i))) {
char c = str.charAt(i);
if (!(c >= '0' && c <= '9')) {
Copy link
Member

Choose a reason for hiding this comment

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

Good!

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ public void testVersionParsing() {
checkVersionParsing("1.2.3-200705301630", 1, 2, 3, 0, "200705301630");
}

public void testVersionParsingNot09() {
String ver = "१.२.३";
assertTrue(Character.isDigit(ver.charAt(0)));
assertTrue(Character.isDigit(ver.charAt(2)));
assertTrue(Character.isDigit(ver.charAt(4)));
ArtifactVersion version = newArtifactVersion(ver);
assertEquals(ver, version.getQualifier());
}
Copy link
Member

Choose a reason for hiding this comment

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

Hold on, shouldn't this fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, as these are not numbers anymore, they are qualifiers (otherwise it would go into major, minor...)

Copy link
Member

Choose a reason for hiding this comment

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

man, I want U+1F4A9 as qualifier!

Copy link
Member Author

Choose a reason for hiding this comment

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

but we must carry thru same change on Resolver as well...


public void testVersionComparing() {
assertVersionEqual("1", "1");
assertVersionOlder("1", "2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,15 @@ public DefaultBeanConfigurationRequest setConfiguration(
return this;
}

private static final String GROUP_ID_ERROR_MESSAGE = "groupId can neither be null, empty, nor blank";
private static final String ARTIFACT_ID_ERROR_MESSAGE = "artifactId can neither be null, empty, nor blank";

private Plugin findPlugin(Model model, String groupId, String artifactId) {
if (Objects.requireNonNull(groupId, "groupId can neither be null, empty nor blank")
.trim()
.isEmpty()) {
throw new IllegalArgumentException("groupId can neither be null, empty nor blank");
if (Objects.requireNonNull(groupId, GROUP_ID_ERROR_MESSAGE).trim().isEmpty()) {
throw new IllegalArgumentException(GROUP_ID_ERROR_MESSAGE);
}
if (Objects.requireNonNull(artifactId, "artifactId can neither be null, empty nor blank")
.trim()
.isEmpty()) {
throw new IllegalArgumentException("artifactId can neither be null, empty nor blank");
if (Objects.requireNonNull(artifactId, ARTIFACT_ID_ERROR_MESSAGE).trim().isEmpty()) {
throw new IllegalArgumentException(ARTIFACT_ID_ERROR_MESSAGE);
}

if (model != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ public String getMavenVersion() {
return mavenVersion;
}

private static final String VERSION_RANGE_ERROR_MESSAGE = "versionRange can neither be null, empty, nor blank";

public boolean isMavenVersion(String versionRange) {
if (Objects.requireNonNull(versionRange, "versionRange can neither be null, empty nor blank")
if (Objects.requireNonNull(versionRange, VERSION_RANGE_ERROR_MESSAGE)
.trim()
.isEmpty()) {
throw new IllegalArgumentException("versionRange can neither be null, empty nor blank");
throw new IllegalArgumentException(VERSION_RANGE_ERROR_MESSAGE);
}
VersionScheme versionScheme = new GenericVersionScheme();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ public void testCalculateDegreeOfConcurrency() {
int cpus = Runtime.getRuntime().availableProcessors();
assertEquals((int) (cpus * 2.2), cli.calculateDegreeOfConcurrency("2.2C"));
assertEquals(1, cli.calculateDegreeOfConcurrency("0.0001C"));
// Note: this assertion below makes no sense, first Float.parseFloat("2.") DOES parse the string in 2.0.
// Second, the limitation to reject string "2." was actually commons-lang3 NumberUtils.isParsable limitation
// We should not "skew" our input validation by some utility, while using Java classes to perform actual parsing
// assertThrows(IllegalArgumentException.class, new ConcurrencyCalculator("2.C"));
assertThrows(IllegalArgumentException.class, new ConcurrencyCalculator("-2.2C"));
assertThrows(IllegalArgumentException.class, new ConcurrencyCalculator("0C"));
}
Expand Down