Copilot commented on code in PR #9281:
URL: https://github.com/apache/seatunnel/pull/9281#discussion_r2076636460
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/SeaTunnelServerStarter.java:
##########
@@ -65,19 +67,25 @@ private static HazelcastInstanceImpl
initializeHazelcastInstance(
: HazelcastInstanceFactory.createInstanceName(
seaTunnelConfig.getHazelcastConfig());
- HazelcastInstanceImpl original =
- ((HazelcastInstanceProxy)
- HazelcastInstanceFactory.newHazelcastInstance(
- seaTunnelConfig.getHazelcastConfig(),
- instanceName,
- new
SeaTunnelNodeContext(seaTunnelConfig)))
- .getOriginal();
- // init telemetry instance
- if (condition) {
- initTelemetryInstance(original.node);
+ try {
+ HazelcastInstanceImpl original =
+ ((HazelcastInstanceProxy)
+
HazelcastInstanceFactory.newHazelcastInstance(
+
seaTunnelConfig.getHazelcastConfig(),
+ instanceName,
+ new
SeaTunnelNodeContext(seaTunnelConfig)))
+ .getOriginal();
+ // init telemetry instance
+ if (condition) {
+ initTelemetryInstance(original.node);
+ }
+
+ return original;
+ } catch (Error e) {
+ log.error("Fatal error occurred during Hazelcast server
initialization", e);
+ System.exit(1);
+ throw e;
Review Comment:
[nitpick] After calling System.exit(1), rethrowing the error is redundant
since the JVM will terminate. Consider removing the rethrow for clarity unless
it is required for testing purposes.
```suggestion
```
##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ClientExecuteCommand.java:
##########
@@ -281,10 +281,16 @@ private HazelcastInstance createServerInLocal(
// set the default async executor for Hazelcast InvocationFuture
ConcurrencyUtil.setDefaultAsyncExecutor(CompletableFuture.EXECUTOR);
- return HazelcastInstanceFactory.newHazelcastInstance(
- seaTunnelConfig.getHazelcastConfig(),
- Thread.currentThread().getName(),
- new SeaTunnelNodeContext(seaTunnelConfig));
+ try {
+ return HazelcastInstanceFactory.newHazelcastInstance(
+ seaTunnelConfig.getHazelcastConfig(),
+ Thread.currentThread().getName(),
+ new SeaTunnelNodeContext(seaTunnelConfig));
+ } catch (Error e) {
+ log.error("Fatal error occurred during Hazelcast instance
initialization", e);
+ System.exit(1);
+ throw e;
Review Comment:
[nitpick] Rethrowing the exception after calling System.exit(1) is
redundant. Consider removing the rethrow to avoid unreachable code or adding a
clarifying comment if needed for testing.
```suggestion
// Note: The following line is unreachable due to
System.exit(1).
// Uncomment for testing purposes if System.exit is mocked.
// throw e;
```
##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/SeaTunnelHazelcastClient.java:
##########
@@ -33,20 +33,29 @@
import com.hazelcast.internal.util.Preconditions;
import com.hazelcast.logging.ILogger;
import lombok.NonNull;
+import lombok.extern.slf4j.Slf4j;
import java.util.UUID;
import java.util.function.Function;
+@Slf4j
public class SeaTunnelHazelcastClient {
private final HazelcastClientInstanceImpl hazelcastClient;
private final SerializationService serializationService;
public SeaTunnelHazelcastClient(@NonNull ClientConfig clientConfig) {
Preconditions.checkNotNull(clientConfig, "hazelcast client config
cannot be null");
- this.hazelcastClient =
- ((HazelcastClientProxy)
HazelcastClient.newHazelcastClient(clientConfig)).client;
- this.serializationService = hazelcastClient.getSerializationService();
-
ExceptionUtil.registerSeaTunnelExceptions(hazelcastClient.getClientExceptionFactory());
+ try {
+ this.hazelcastClient =
+ ((HazelcastClientProxy)
HazelcastClient.newHazelcastClient(clientConfig))
+ .client;
+ this.serializationService =
hazelcastClient.getSerializationService();
+
ExceptionUtil.registerSeaTunnelExceptions(hazelcastClient.getClientExceptionFactory());
+ } catch (Error e) {
+ log.error("Fatal error occurred during Hazelcast client
initialization", e);
+ System.exit(1);
+ throw e;
Review Comment:
[nitpick] The rethrow after System.exit(1) is generally unnecessary since
the process will terminate. Consider removing or documenting this pattern if it
serves a specific testing purpose.
```suggestion
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]