Copilot commented on code in PR #2940:
URL:
https://github.com/apache/incubator-hugegraph/pull/2940#discussion_r2726809338
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java:
##########
@@ -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();
+ }
Review Comment:
The lazy initialization in the graph() method is not thread-safe. If
multiple test threads call graph() concurrently before initialization
completes, they could trigger multiple initializations simultaneously,
potentially causing race conditions, resource conflicts, or duplicate graph
instances. Consider adding synchronization using a synchronized block or
double-checked locking pattern to ensure only one thread performs the
initialization.
--
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]