DATACMNS-496 - Version.parse(…) now drops non-numeric artifacts.
Version parsing failed when given version contained non-numeric parts (like 2.0.0-rc1). We now strip everything after the first non numeric part to create a logical version equivalent of the source String. Original pull request: #81.
This commit is contained in:
committed by
Oliver Gierke
parent
ec49499e50
commit
57271baf54
@@ -53,7 +53,7 @@ public class Version implements Comparable<Version> {
|
||||
int[] intParts = new int[parts.length];
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
intParts[i] = Integer.parseInt(parts[i]);
|
||||
intParts[i] = Integer.parseInt(parts[i].replaceAll("\\D.*", ""));
|
||||
}
|
||||
|
||||
return new Version(intParts);
|
||||
|
||||
@@ -123,4 +123,12 @@ public class VersionUnitTests {
|
||||
assertThat(new Version(2, 0, 1, 0).toString(), is("2.0.1"));
|
||||
assertThat(new Version(2, 0, 0, 1).toString(), is("2.0.0.1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-496
|
||||
*/
|
||||
@Test
|
||||
public void parseShouldRemoveNonNumericVersionParts() {
|
||||
assertThat(Version.parse("2.0.0-rc1"), is(new Version(2, 0, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user