Merge pull request #3816 from mark4z/develop

[ISSUE#3787]  fix ConvertUtils can not handle FormatException.
This commit is contained in:
杨翊 SionYang 2020-09-14 14:55:22 +08:00 committed by GitHub
commit dc5cba2e69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,11 @@ public final class ConvertUtils {
if (StringUtils.isBlank(val)) {
return defaultValue;
}
return Integer.parseInt(val);
try {
return Integer.parseInt(val);
} catch (NumberFormatException exception) {
return defaultValue;
}
}
/**
@ -77,7 +81,11 @@ public final class ConvertUtils {
if (StringUtils.isBlank(val)) {
return defaultValue;
}
return Long.parseLong(val);
try {
return Long.parseLong(val);
} catch (NumberFormatException exception) {
return defaultValue;
}
}
/**
@ -92,7 +100,11 @@ public final class ConvertUtils {
if (StringUtils.isBlank(val)) {
return defaultValue;
}
return Boolean.parseBoolean(val);
try {
return Boolean.parseBoolean(val);
} catch (NumberFormatException exception) {
return defaultValue;
}
}
// The following utility functions are extracted from <link>org.apache.commons.lang3</link>