imbajin commented on code in PR #683:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/683#discussion_r2422428601
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/HugeGraphLoader.java:
##########
@@ -109,42 +203,62 @@ public boolean load() {
// Print load summary
Printer.printSummary(this.context);
} catch (Throwable t) {
+ this.context.occurredError();
+
+ if (t instanceof ServerException) {
+ ServerException e = (ServerException) t;
+ String logMessage =
+ "Log ServerException: \n" + e.exception() + "\n";
+ if (e.trace() != null) {
+ logMessage += StringUtils.join((List<String>) e.trace(),
+ "\n");
+ }
+ LOG.warn(logMessage);
+ }
+
RuntimeException e = LoadUtil.targetRuntimeException(t);
Printer.printError("Failed to load", e);
- if (this.context.options().testMode) {
- throw e;
- }
- } finally {
- this.stopThenShutdown();
+ e.printStackTrace();
+
+ throw e;
}
- return this.context.noError();
+
+ // 任务执行成功
Review Comment:
**Resource Management Issue**: The `finally` block that calls
`this.stopThenShutdown()` has been removed from the `load()` method. This
creates a serious resource leak risk.
**Problem**: If an exception occurs during loading, resources may not be
properly cleaned up since `stopThenShutdown()` won't be called.
**Recommendation**: Restore the finally block to ensure proper resource
cleanup:
```java
public boolean load() {
try {
// ... loading logic ...
} catch (Throwable t) {
// ... error handling ...
throw e;
} finally {
this.stopThenShutdown(); // Always cleanup resources
}
return true;
}
```
Alternatively, ensure that callers explicitly invoke `shutdown()` in their
own finally blocks, which is less robust.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]