Hisoka-X commented on code in PR #9281:
URL: https://github.com/apache/seatunnel/pull/9281#discussion_r2084481422


##########
seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/SeaTunnel.java:
##########
@@ -40,9 +40,11 @@ public static <T extends CommandArgs> void run(Command<T> 
command) throws Comman
             command.execute();
         } catch (ConfigRuntimeException e) {
             showConfigError(e);
+            System.exit(1);
             throw e;

Review Comment:
   ```suggestion
   ```



##########
seatunnel-core/seatunnel-flink-starter/seatunnel-flink-15-starter/src/test/java/org/apache/seatunnel/core/starter/flink/FlinkCommandArgsTest.java:
##########
@@ -42,18 +42,31 @@ public void testExecuteClientCommandArgsWithPluginName()
     }
 
     @Test
-    public void testExecuteClientCommandArgsWithoutPluginName()
-            throws FileNotFoundException, URISyntaxException {
+    public void testExecuteClientCommandArgsWithoutPluginName() throws 
Exception {
         String configurePath = 
"/config/fake_to_inmemory_without_pluginname.json";
         String configFile = 
MultiTableSinkTest.getTestConfigFile(configurePath);
         FlinkCommandArgs flinkCommandArgs = buildFlinkCommandArgs(configFile);
-        ConfigException configException =
-                Assertions.assertThrows(
-                        ConfigException.class,
-                        () -> SeaTunnel.run(flinkCommandArgs.buildCommand()));
-        Assertions.assertEquals(
-                String.format("No configuration setting found for key '%s'", 
PLUGIN_NAME.key()),
-                configException.getMessage());
+
+        // Catch System.exit call and verify exit code
+        int statusCode =
+                catchSystemExit(
+                        () -> {
+                            try {
+                                SeaTunnel.run(flinkCommandArgs.buildCommand());
+                            } catch (CommandExecuteException e) {
+                                // Verify the exception message
+                                Assertions.assertEquals(
+                                        String.format(
+                                                "No configuration setting 
found for key '%s'",
+                                                PLUGIN_NAME.key()),
+                                        e.getCause().getMessage());
+                                // Re-throw to ensure the test fails if 
System.exit is not called
+                                throw e;

Review Comment:
   I believe the catch block will never reach. We can delete it.



##########
seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/SeaTunnel.java:
##########
@@ -40,9 +40,11 @@ public static <T extends CommandArgs> void run(Command<T> 
command) throws Comman
             command.execute();
         } catch (ConfigRuntimeException e) {
             showConfigError(e);
+            System.exit(1);
             throw e;
-        } catch (Exception e) {
+        } catch (Exception | Error e) {
             showFatalError(e);
+            System.exit(1);
             throw e;

Review Comment:
   ```suggestion
   ```



##########
seatunnel-core/seatunnel-spark-starter/seatunnel-spark-3-starter/src/test/java/org/apache/seatunnel/core/starter/spark/SparkCommandArgsTest.java:
##########
@@ -43,19 +44,32 @@ public void testExecuteClientCommandArgsWithPluginName()
     }
 
     @Test
-    public void testExecuteClientCommandArgsWithoutPluginName()
-            throws FileNotFoundException, URISyntaxException {
+    public void testExecuteClientCommandArgsWithoutPluginName() throws 
Exception {
         String configurePath = 
"/config/fake_to_inmemory_without_pluginname.json";
         String configFile = 
MultiTableSinkTest.getTestConfigFile(configurePath);
         SparkCommandArgs sparkCommandArgs = buildSparkCommands(configFile);
         sparkCommandArgs.setDeployMode(DeployMode.CLIENT);
-        CommandExecuteException commandExecuteException =
-                Assertions.assertThrows(
-                        CommandExecuteException.class,
-                        () -> SeaTunnel.run(sparkCommandArgs.buildCommand()));
-        Assertions.assertEquals(
-                String.format("No configuration setting found for key '%s'", 
PLUGIN_NAME.key()),
-                commandExecuteException.getCause().getMessage());
+
+        // Catch System.exit call and verify exit code
+        int statusCode =
+                catchSystemExit(
+                        () -> {
+                            try {
+                                SeaTunnel.run(sparkCommandArgs.buildCommand());
+                            } catch (CommandExecuteException e) {
+                                // Verify the exception message
+                                Assertions.assertEquals(

Review Comment:
   ditto



##########
seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgsTest.java:
##########
@@ -51,20 +52,31 @@ public void testSetJobId() throws FileNotFoundException, 
URISyntaxException {
     }
 
     @Test
-    public void testExecuteClientCommandArgsWithoutPluginName()
-            throws FileNotFoundException, URISyntaxException {
+    public void testExecuteClientCommandArgsWithoutPluginName() throws 
Exception {
         String configurePath = 
"/config/fake_to_inmemory_without_pluginname.json";
         String configFile = 
MultiTableSinkTest.getTestConfigFile(configurePath);
         ClientCommandArgs clientCommandArgs = 
buildClientCommandArgs(configFile);
-        CommandExecuteException commandExecuteException =
-                Assertions.assertThrows(
-                        CommandExecuteException.class,
-                        () -> SeaTunnel.run(clientCommandArgs.buildCommand()));
-        Assertions.assertEquals(
-                String.format(
-                        "The '%s' option is not configured, please configure 
it.",
-                        PLUGIN_NAME.key()),
-                commandExecuteException.getCause().getMessage());
+
+        // Catch System.exit call and verify exit code
+        int statusCode =
+                catchSystemExit(
+                        () -> {
+                            try {
+                                
SeaTunnel.run(clientCommandArgs.buildCommand());
+                            } catch (CommandExecuteException e) {
+                                // Verify the exception message
+                                Assertions.assertEquals(

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to