mirror of https://github.com/apache/maven.git
[MNG-8349] Avoid exceptions with invalid modelVersion (#1848)
This commit is contained in:
parent
7c091a14c9
commit
9f2ef34343
|
@ -1963,8 +1963,7 @@ public class DefaultModelValidator implements ModelValidator {
|
||||||
String[] firstSegments = first.split("\\.");
|
String[] firstSegments = first.split("\\.");
|
||||||
String[] secondSegments = second.split("\\.");
|
String[] secondSegments = second.split("\\.");
|
||||||
for (int i = 0; i < Math.max(firstSegments.length, secondSegments.length); i++) {
|
for (int i = 0; i < Math.max(firstSegments.length, secondSegments.length); i++) {
|
||||||
int result = Long.valueOf(i < firstSegments.length ? firstSegments[i] : "0")
|
int result = asLong(i, firstSegments).compareTo(asLong(i, secondSegments));
|
||||||
.compareTo(Long.valueOf(i < secondSegments.length ? secondSegments[i] : "0"));
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1972,6 +1971,14 @@ public class DefaultModelValidator implements ModelValidator {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Long asLong(int index, String[] segments) {
|
||||||
|
try {
|
||||||
|
return Long.valueOf(index < segments.length ? segments[index] : "0");
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("checkstyle:parameternumber")
|
@SuppressWarnings("checkstyle:parameternumber")
|
||||||
private boolean validateBannedCharacters(
|
private boolean validateBannedCharacters(
|
||||||
String prefix,
|
String prefix,
|
||||||
|
|
Loading…
Reference in New Issue