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..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 @@ -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; @@ -52,11 +51,29 @@ 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; }