Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.hugegraph.testutil.Utils;
import org.apache.hugegraph.util.Log;
import org.junit.AfterClass;
import org.junit.Assert;
Comment thread
JisoLya marked this conversation as resolved.
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
Expand All @@ -52,11 +51,18 @@
public class CoreTestSuite {

private static boolean registered = false;
Comment thread
imbajin marked this conversation as resolved.
private static HugeGraph graph = null;
private static volatile HugeGraph graph = null;
Comment thread
JisoLya marked this conversation as resolved.

Comment thread
JisoLya marked this conversation as resolved.
public static HugeGraph graph() {
Assert.assertNotNull(graph);
//Assert.assertFalse(graph.closed());
Comment thread
JisoLya marked this conversation as resolved.
Outdated
if (graph == null) {
synchronized (CoreTestSuite.class){
if (graph == null) {
initEnv();
init();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ Critical: Exception handling concern in lazy initialization

The initEnv() and init() methods can throw exceptions. If an exception occurs inside the synchronized block:

  1. graph remains null
  2. Subsequent calls will retry initialization (possibly desirable, but may cause repeated failures)

Consider whether failed initialization should be remembered to provide a clearer error message on subsequent calls, or at minimum document this behavior.

Also, there's an ordering dependency: initEnv() must complete before init(). While this works with the current registered flag, consider whether you need additional error handling if initEnv() succeeds but init() fails.

}
}
}
Comment thread
JisoLya marked this conversation as resolved.
return graph;
}

Expand Down
Loading