diff --git a/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbGroup.java b/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbGroup.java index 1b7962c3b5..beeab20531 100644 --- a/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbGroup.java +++ b/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbGroup.java @@ -292,13 +292,13 @@ private void checkRule(LinkedHashMap row) { String delayThresholdStr = row.get(COLUMN_DELAY_THRESHOLD); String heartbeatTimeoutStr = row.get(COLUMN_HEARTBEAT_TIMEOUT); String heartbeatRetryStr = row.get(COLUMN_HEARTBEAT_RETRY); - if (!StringUtil.isBlank(delayThresholdStr) && IntegerUtil.parseInt(delayThresholdStr) < -1) { + if (StringUtil.isBlank(delayThresholdStr) || IntegerUtil.parseInt(delayThresholdStr) < -1) { throw new ConfigException("Column '" + COLUMN_DELAY_THRESHOLD + "' should be an integer greater than or equal to -1!"); } - if (!StringUtil.isBlank(heartbeatTimeoutStr) && IntegerUtil.parseInt(heartbeatTimeoutStr) < 0) { + if (StringUtil.isBlank(heartbeatTimeoutStr) || IntegerUtil.parseInt(heartbeatTimeoutStr) < 0) { throw new ConfigException("Column '" + COLUMN_HEARTBEAT_TIMEOUT + "' should be an integer greater than or equal to 0!"); } - if (!StringUtil.isBlank(heartbeatRetryStr) && IntegerUtil.parseInt(heartbeatRetryStr) < 0) { + if (StringUtil.isBlank(heartbeatRetryStr) || IntegerUtil.parseInt(heartbeatRetryStr) < 0) { throw new ConfigException("Column '" + COLUMN_HEARTBEAT_RETRY + "' should be an integer greater than or equal to 0!"); } String heartbeatKeepAliveStr = row.get(COLUMN_KEEP_ALIVE); diff --git a/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbInstance.java b/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbInstance.java index 98e1eaeb9e..595680fe44 100644 --- a/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbInstance.java +++ b/src/main/java/com/actiontech/dble/services/manager/information/tables/DbleDbInstance.java @@ -402,6 +402,8 @@ private DBInstance transformRowToDBInstance(LinkedHashMap map) { DBInstance dbInstance = new DBInstance(); StringBuilder url = new StringBuilder(); List propertyList = Lists.newArrayList(); + String key; + String entryValue; for (Map.Entry entry : map.entrySet()) { switch (entry.getKey()) { case COLUMN_NAME: @@ -469,6 +471,13 @@ private DBInstance transformRowToDBInstance(LinkedHashMap map) { case COLUMN_TEST_ON_BORROW: case COLUMN_TEST_ON_RETURN: case COLUMN_TEST_WHILE_IDLE: + key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey()); + entryValue = entry.getValue(); + if (StringUtil.isBlank(entryValue) || (!StringUtil.equalsIgnoreCase(entryValue, Boolean.FALSE.toString()) && !StringUtil.equalsIgnoreCase(entryValue, Boolean.TRUE.toString()))) { + throw new ConfigException("Column '" + entry.getKey() + "' values only support 'false' or 'true'."); + } + propertyList.add(new Property(entryValue, key)); + break; case COLUMN_CONNECTION_TIMEOUT: case COLUMN_CONNECTION_HEARTBEAT_TIMEOUT: case COLUMN_TIME_BETWEEN_EVICTION_RUNS_MILLIS: @@ -477,8 +486,12 @@ private DBInstance transformRowToDBInstance(LinkedHashMap map) { case COLUMN_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS: case COLUMN_FLOW_HIGH_LEVEL: case COLUMN_FLOW_LOW_LEVEL: - String key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey()); - propertyList.add(new Property(entry.getValue(), key)); + key = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.getKey()); + entryValue = entry.getValue(); + if (StringUtil.isBlank(entryValue) || IntegerUtil.parseInt(entryValue) <= 0) { + throw new ConfigException("Column '" + entry.getKey() + "' should be an integer greater than 0!"); + } + propertyList.add(new Property(entryValue, key)); break; default: break;