imbajin commented on code in PR #683:
URL: 
https://github.com/apache/incubator-hugegraph-toolchain/pull/683#discussion_r2422430155


##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/HugeGraphLoader.java:
##########
@@ -59,14 +88,34 @@ public final class HugeGraphLoader {
     private final LoadContext context;
     private final LoadMapping mapping;
     private final TaskManager manager;
+    private final LoadOptions options;
+
+    // load 任务执行线程池
+    private ExecutorService loadService;

Review Comment:
   **Thread Safety Concern**: The `loadService` ExecutorService is created as 
an instance field but is only initialized in `loadStructs()`. This could lead 
to NullPointerException if methods are called in unexpected order.
   
   **Recommendation**: Initialize the executor in the constructor or use lazy 
initialization with proper synchronization:
   ```java
   private volatile ExecutorService loadService;
   
   private synchronized ExecutorService getLoadService(int parallelCount) {
       if (loadService == null) {
           loadService = ExecutorUtil.newFixedThreadPool(parallelCount, 
"loader");
       }
       return loadService;
   }
   ```
   
   Also ensure proper shutdown in all code paths.



-- 
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]

Reply via email to