Skip to content

Commit

Permalink
Add safety check
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed Mar 14, 2022
1 parent 244ec24 commit 90eefa0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/io/micronaut/build/compat/VersionModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ public static VersionModel of(String version) {

private VersionModel(String current, VersionModel leaf) {
this.current = current;
this.currentAsInt = Integer.parseInt(current);
this.currentAsInt = parseInt(current);
this.leaf = leaf;
}

private static int parseInt(String current) {
try {
return Integer.parseInt(current);
} catch (NumberFormatException e) {
return 0;
}
}

@Override
public int compareTo(@NotNull VersionModel o) {
int result = Integer.compare(currentAsInt, o.currentAsInt);
Expand Down

0 comments on commit 90eefa0

Please sign in to comment.