From 7daa18578380e5ad5f2d9721bde614a752080207 Mon Sep 17 00:00:00 2001 From: guoaomen Date: Mon, 10 Jul 2023 17:03:08 +0800 Subject: [PATCH] fix[inner-2283]: heartbeat_keep_alive add null value judgment --- .../information/tables/DbleDbGroup.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) 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 beeab20531..f34664a419 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 @@ -289,30 +289,30 @@ 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) { - 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) { - 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) { - throw new ConfigException("Column '" + COLUMN_HEARTBEAT_RETRY + "' should be an integer greater than or equal to 0!"); - } - String heartbeatKeepAliveStr = row.get(COLUMN_KEEP_ALIVE); - if (!StringUtil.isBlank(heartbeatKeepAliveStr) && IntegerUtil.parseInt(heartbeatKeepAliveStr) < 0) { - throw new ConfigException("Column '" + COLUMN_KEEP_ALIVE + "' should be an integer greater than or equal to 0!"); - } - String delayPeriodMillis = row.get(DELAY_PERIOD_MILLIS); - delayDetectionCheck(delayPeriodMillis); + checkInterValue(row); } } - private void delayDetectionCheck(String delayPeriodMillis) { - if (!StringUtil.isBlank(delayPeriodMillis) && IntegerUtil.parseInt(delayPeriodMillis) < -1) { - throw new ConfigException("Column '" + COLUMN_DELAY_THRESHOLD + "' should be an integer greater than -1!"); + private void checkInterValue(LinkedHashMap row) { + String delayThresholdStr = row.get(COLUMN_DELAY_THRESHOLD); + String heartbeatTimeoutStr = row.get(COLUMN_HEARTBEAT_TIMEOUT); + String heartbeatRetryStr = row.get(COLUMN_HEARTBEAT_RETRY); + if (row.containsKey(COLUMN_DELAY_THRESHOLD) && (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 (row.containsKey(COLUMN_HEARTBEAT_TIMEOUT) && (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 (row.containsKey(COLUMN_HEARTBEAT_RETRY) && (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); + if (row.containsKey(COLUMN_KEEP_ALIVE) && (StringUtil.isBlank(heartbeatKeepAliveStr) || IntegerUtil.parseInt(heartbeatKeepAliveStr) < 0)) { + throw new ConfigException("Column '" + COLUMN_KEEP_ALIVE + "' should be an integer greater than or equal to 0!"); + } + String delayPeriodMillis = row.get(DELAY_PERIOD_MILLIS); + if (row.containsKey(DELAY_PERIOD_MILLIS) && (StringUtil.isBlank(delayPeriodMillis) || IntegerUtil.parseInt(delayPeriodMillis) < -1)) { + throw new ConfigException("Column '" + DELAY_PERIOD_MILLIS + "' should be an integer greater than or equal to -1!"); } }