This is an automated email from the ASF dual-hosted git repository.

jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git


The following commit(s) were added to refs/heads/master by this push:
     new 9babe4939 test(server): enable run single unit test (#2940)
9babe4939 is described below

commit 9babe493919c01f012a56e7b5fb4d8b9faf64cf5
Author: Soyaazz <[email protected]>
AuthorDate: Thu Jan 29 16:06:08 2026 +0800

    test(server): enable run single unit test (#2940)
    
    * test(server-test): enable run single unit test
    
    * fix: thread-safe graph() method
    
    * fix: more clear error handling in graph() method
---
 .../org/apache/hugegraph/core/CoreTestSuite.java   | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git 
a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java
 
b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java
index 2ff62b06e..1f870208c 100644
--- 
a/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java
+++ 
b/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java
@@ -26,7 +26,6 @@ import org.apache.hugegraph.meta.PdMetaDriver;
 import org.apache.hugegraph.testutil.Utils;
 import org.apache.hugegraph.util.Log;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
@@ -52,11 +51,29 @@ import org.slf4j.Logger;
 public class CoreTestSuite {
 
     private static boolean registered = false;
-    private static HugeGraph graph = null;
+    private static volatile HugeGraph graph = null;
 
     public static HugeGraph graph() {
-        Assert.assertNotNull(graph);
-        //Assert.assertFalse(graph.closed());
+        if (graph == null) {
+            synchronized (CoreTestSuite.class) {
+                if (graph == null) {
+                    try {
+                        initEnv();
+                        init();
+                    } catch (Throwable e) {
+                        LOG.error("Failed to initialize HugeGraph instance", 
e);
+                        graph = null;
+                        throw new RuntimeException("Failed to initialize 
HugeGraph instance", e);
+                    }
+                    if (graph == null) {
+                        String msg = "HugeGraph instance is null after 
initialization. " +
+                                     "Please check Utils.open() 
configuration.";
+                        LOG.error(msg);
+                        throw new IllegalStateException(msg);
+                    }
+                }
+            }
+        }
         return graph;
     }
 

Reply via email to