mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-27 06:22:07 +01:00
Catch NumberFormatException when parsing integer
This commit is contained in:
parent
c3cc7461f1
commit
6b84517ce8
1 changed files with 8 additions and 1 deletions
|
@ -27,6 +27,7 @@ import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
@ -545,6 +546,12 @@ public final class Configuration {
|
||||||
|
|
||||||
private static int getIntProperty(Properties properties, String propertyName, int defaultValue) {
|
private static int getIntProperty(Properties properties, String propertyName, int defaultValue) {
|
||||||
String s = properties.getProperty(propertyName, Integer.toString(defaultValue));
|
String s = properties.getProperty(propertyName, Integer.toString(defaultValue));
|
||||||
return Integer.parseInt(s);
|
try {
|
||||||
|
return Integer.parseInt(s);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
LOGGER.log(Level.WARNING, "Could not parse value of property " + propertyName +
|
||||||
|
". Using default value " + defaultValue + " instead.");
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue