Skip to content

Commit

Permalink
Protect against number format errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianromero committed Jul 23, 2019
1 parent c6aeaf7 commit c91bafd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ protected MiniVar valueImpl(String value) {
if (value == null || value.isEmpty()) {
return MiniVarDouble.NULL;
} else {
return new MiniVarDouble(Double.parseDouble(value));
try {
return new MiniVarDouble(Double.parseDouble(value));
} catch (NumberFormatException ex) {
return MiniVarDouble.NULL;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ protected MiniVar valueImpl(String value) {
if (value == null || value.isEmpty()) {
return MiniVarInt.NULL;
} else {
return new MiniVarInt(Integer.parseInt(value));
try {
return new MiniVarInt(Integer.parseInt(value));
} catch(NumberFormatException ex) {
return MiniVarInt.NULL;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ protected MiniVar valueImpl(String value) {
if (value == null || value.isEmpty()) {
return MiniVarLong.NULL;
} else {
return new MiniVarLong(Long.parseLong(value));
try {
return new MiniVarLong(Long.parseLong(value));
} catch (NumberFormatException ex) {
return MiniVarLong.NULL;
}
}
}

Expand Down

0 comments on commit c91bafd

Please sign in to comment.