This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 6a037a24e9f Fix DN does not exit due to exception handling failure
(#16254)
6a037a24e9f is described below
commit 6a037a24e9f8e25db3ad2696006ab8ec37838f40
Author: Jiang Tian <[email protected]>
AuthorDate: Wed Aug 27 09:56:11 2025 +0800
Fix DN does not exit due to exception handling failure (#16254)
---
.../apache/iotdb/db/it/IoTDBCustomizedClusterIT.java | 20 ++++++++++++++++++++
.../org/apache/iotdb/commons/utils/StatusUtils.java | 18 +++++++++++-------
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
index b0c1f426822..74391b99bb3 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBCustomizedClusterIT.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.DailyIT;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.session.Session;
import org.junit.Test;
@@ -41,6 +42,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -268,4 +270,22 @@ public class IoTDBCustomizedClusterIT {
simpleEnv.cleanClusterEnvironment();
}
}
+
+ @Test
+ public void testStartWithWrongConfig() throws InterruptedException {
+ SimpleEnv simpleEnv = new SimpleEnv();
+ simpleEnv
+ .getConfig()
+ .getCommonConfig()
+
.setDataRegionConsensusProtocolClass("org.apache.iotdb.consensus.iot.IoTConsensusV1");
+ try {
+ simpleEnv.initClusterEnvironment(1, 1);
+ } catch (AssertionError e) {
+ // ignore
+ }
+ simpleEnv.getDataNodeWrapper(0).getInstance().waitFor(20,
TimeUnit.SECONDS);
+ assertEquals(
+ TSStatusCode.ILLEGAL_PARAMETER.getStatusCode(),
+ simpleEnv.getDataNodeWrapper(0).getInstance().exitValue());
+ }
}
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
index ed327969c35..e7df20935b2 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/StatusUtils.java
@@ -25,8 +25,6 @@ import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.rpc.RpcUtils;
import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.ratis.util.ExitUtils;
-
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
@@ -251,13 +249,19 @@ public class StatusUtils {
}
public static int retrieveExitStatusCode(Throwable e) {
- if (e instanceof ExitUtils.ExitException && e.getCause() != null) {
+ while (e.getCause() != null) {
e = e.getCause();
}
- if (e.getMessage().contains("because Could not create ServerSocket")
- || e.getMessage().contains("Failed to bind to address")
- || e.getMessage().contains("Address already in use: bind")) {
- return TSStatusCode.PORT_OCCUPIED.getStatusCode();
+ if (e.getMessage() != null) {
+ if (e.getMessage().contains("because Could not create ServerSocket")
+ || e.getMessage().contains("Failed to bind to address")
+ || e.getMessage().contains("Address already in use: bind")) {
+ return TSStatusCode.PORT_OCCUPIED.getStatusCode();
+ }
+
+ if (e instanceof ClassNotFoundException || e instanceof
IllegalArgumentException) {
+ return TSStatusCode.ILLEGAL_PARAMETER.getStatusCode();
+ }
}
return -1;
}