Catch NumberFormatException when parsing integer

This commit is contained in:
Paul Schaub 2019-09-28 01:32:11 +02:00
부모 c3cc7461f1
커밋 6b84517ce8
로그인 계정: vanitasvitae
GPG 키 ID: 62BEE9264BF17311
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제

파일 보기

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLContext;
@ -545,6 +546,12 @@ public final class Configuration {
private static int getIntProperty(Properties properties, String propertyName, int 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;
}
}
}