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

mchades pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 9703039d9 [#5969] fix(Docker): Failed to create Docker network by 
concurrent execution ITs (#5970)
9703039d9 is described below

commit 9703039d9406138c9387376c0b46842c3dcf72e8
Author: Xun <[email protected]>
AuthorDate: Tue Dec 24 16:19:08 2024 +0800

    [#5969] fix(Docker): Failed to create Docker network by concurrent 
execution ITs (#5970)
    
    ### What changes were proposed in this pull request?
    
    Uses thread safe to create Docker network
    
    ### Why are the changes needed?
    
    
    Fix: #5969
    
    ### Does this PR introduce _any_ user-facing change?
    
    N/A
    
    ### How was this patch tested?
    
    CI Passed.
---
 .../integration/test/container/ContainerSuite.java | 32 ++++++++++++----------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git 
a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/ContainerSuite.java
 
b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/ContainerSuite.java
index 5745cc6d0..d2a5ee615 100644
--- 
a/integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/ContainerSuite.java
+++ 
b/integration-test-common/src/test/java/org/apache/gravitino/integration/test/container/ContainerSuite.java
@@ -86,22 +86,24 @@ public class ContainerSuite implements Closeable {
   protected static final CloseableGroup closer = CloseableGroup.create();
 
   private static void initIfNecessary() {
-    if (initialized) {
-      return;
-    }
-
-    try {
-      // Check if docker is available and you should never close the global 
DockerClient!
-      DockerClient dockerClient = DockerClientFactory.instance().client();
-      Info info = dockerClient.infoCmd().exec();
-      LOG.info("Docker info: {}", info);
-
-      if 
("true".equalsIgnoreCase(System.getenv("NEED_CREATE_DOCKER_NETWORK"))) {
-        network = createDockerNetwork();
+    if (!initialized) {
+      synchronized (ContainerSuite.class) {
+        if (!initialized) {
+          try {
+            // Check if docker is available and you should never close the 
global DockerClient!
+            DockerClient dockerClient = 
DockerClientFactory.instance().client();
+            Info info = dockerClient.infoCmd().exec();
+            LOG.info("Docker info: {}", info);
+
+            if 
("true".equalsIgnoreCase(System.getenv("NEED_CREATE_DOCKER_NETWORK"))) {
+              network = createDockerNetwork();
+            }
+            initialized = true;
+          } catch (Exception e) {
+            throw new RuntimeException("Failed to initialize ContainerSuite", 
e);
+          }
+        }
       }
-      initialized = true;
-    } catch (Exception e) {
-      throw new RuntimeException("Failed to initialize ContainerSuite", e);
     }
   }
 

Reply via email to