Make getIntegerProperty() more robust by catching and logging NumberFormatExceptions.
This commit is contained in:
parent
5fe2b74d30
commit
3d882de822
1 changed files with 6 additions and 2 deletions
|
@ -444,11 +444,15 @@ public final class Relation {
|
||||||
|
|
||||||
private int getIntegerProperty(String name, Properties props, int defaultValue) {
|
private int getIntegerProperty(String name, Properties props, int defaultValue) {
|
||||||
Object value = props.get(name);
|
Object value = props.get(name);
|
||||||
|
|
||||||
if (value instanceof Number) {
|
if (value instanceof Number) {
|
||||||
return ((Number) value).intValue();
|
return ((Number) value).intValue();
|
||||||
} else if (value instanceof String) {
|
} else if (value instanceof String) {
|
||||||
|
try {
|
||||||
return Integer.parseInt((String) value);
|
return Integer.parseInt((String) value);
|
||||||
|
} catch (NumberFormatException nfx) {
|
||||||
|
ownType.getApplication().logError("Can't parse integer for property "
|
||||||
|
+ name + " from value " + value, nfx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue