Unverified 提交 469a69ea authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #817 from katzyn/misc

Parse also 1 as true and 0 as false in Utils.parseBoolean()
......@@ -334,15 +334,7 @@ public class ConnectionInfo implements Cloneable {
* @return the value
*/
boolean getProperty(String key, boolean defaultValue) {
String x = getProperty(key, null);
if (x == null) {
return defaultValue;
}
// support 0 / 1 (like the parser)
if (x.length() == 1 && Character.isDigit(x.charAt(0))) {
return Integer.parseInt(x) != 0;
}
return Boolean.parseBoolean(x);
return Utils.parseBoolean(getProperty(key, null), defaultValue, false);
}
/**
......
......@@ -659,10 +659,10 @@ public class Utils {
if (value == null) {
return defaultValue;
}
if (value.equalsIgnoreCase("true")) {
if (value.equalsIgnoreCase("true") || value.equals("1")) {
return true;
}
if (value.equalsIgnoreCase("false")) {
if (value.equalsIgnoreCase("false") || value.equals("0")) {
return false;
}
if (throwException) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论