From 5d0922bce25f1fe12deb9bf1aea259970c02892a Mon Sep 17 00:00:00 2001 From: JisoLya <523420504@qq.com> Date: Tue, 20 Jan 2026 16:30:09 +0800 Subject: [PATCH 1/3] test(server-test): enable run single unit test --- .../main/java/org/apache/hugegraph/core/CoreTestSuite.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 2ff62b06ef..c9c4e6d6da 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.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; @@ -55,8 +54,11 @@ public class CoreTestSuite { private static HugeGraph graph = null; public static HugeGraph graph() { - Assert.assertNotNull(graph); //Assert.assertFalse(graph.closed()); + if (graph == null) { + initEnv(); + init(); + } return graph; } From 5c6269d85f6a13e56a45638d75751e04cb2b6878 Mon Sep 17 00:00:00 2001 From: JisoLya <523420504@qq.com> Date: Tue, 27 Jan 2026 17:37:25 +0800 Subject: [PATCH 2/3] fix: thread-safe graph() method --- .../java/org/apache/hugegraph/core/CoreTestSuite.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 c9c4e6d6da..50c11595fd 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 @@ -51,13 +51,17 @@ public class CoreTestSuite { private static boolean registered = false; - private static HugeGraph graph = null; + private static volatile HugeGraph graph = null; public static HugeGraph graph() { //Assert.assertFalse(graph.closed()); if (graph == null) { - initEnv(); - init(); + synchronized (CoreTestSuite.class){ + if (graph == null) { + initEnv(); + init(); + } + } } return graph; } From 7b306b669d710798433607abc5bcd7bceb56704f Mon Sep 17 00:00:00 2001 From: JisoLya <523420504@qq.com> Date: Tue, 27 Jan 2026 22:02:17 +0800 Subject: [PATCH 3/3] fix: more clear error handling in graph() method --- .../apache/hugegraph/core/CoreTestSuite.java | 19 +++++++++++++++---- 1 file changed, 15 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 50c11595fd..1f870208c9 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 @@ -54,12 +54,23 @@ public class CoreTestSuite { private static volatile HugeGraph graph = null; public static HugeGraph graph() { - //Assert.assertFalse(graph.closed()); if (graph == null) { - synchronized (CoreTestSuite.class){ + synchronized (CoreTestSuite.class) { if (graph == null) { - initEnv(); - init(); + 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); + } } } }