You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ba...@apache.org on 2025/03/07 07:17:47 UTC

(pulsar) 06/15: [improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (#24004)

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

baodi pushed a commit to branch branch-3.0.10
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit ee0ac0b214c81022d5d6fe7ab1fdb4dd1478d940
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Sat Feb 22 10:27:10 2025 +0200

    [improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (#24004)
    
    (cherry picked from commit 35c9fec78917cc2e03247f9a447d8464c91e7878)
    (cherry picked from commit 49ca5d6dcaac8d804602388809d516354ad41554)
---
 .mvn/extensions.xml                                |  2 +-
 .../pulsar/metadata/BaseMetadataStoreTest.java     | 36 ++++++++++++++++------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index 8ceede33b9c..22eaa6a1779 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -24,7 +24,7 @@
   <extension>
     <groupId>com.gradle</groupId>
     <artifactId>develocity-maven-extension</artifactId>
-    <version>1.22.2</version>
+    <version>1.23.1</version>
   </extension>
   <extension>
     <groupId>com.gradle</groupId>
diff --git a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java
index c4bd1959acc..5282507d5c4 100644
--- a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java
+++ b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java
@@ -25,6 +25,7 @@ import io.etcd.jetcd.test.EtcdClusterExtension;
 import java.io.File;
 import java.net.URI;
 import java.util.Arrays;
+import java.util.Optional;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CompletionException;
@@ -128,11 +129,11 @@ public abstract class BaseMetadataStoreTest extends TestRetrySupport {
         // The new connection string won't be available to the test method unless a
         // Supplier<String> lambda is used for providing the value.
         return new Object[][]{
-                {"ZooKeeper", stringSupplier(() -> zksConnectionString)},
-                {"Memory", stringSupplier(() -> memoryConnectionString)},
-                {"RocksDB", stringSupplier(() -> rocksdbConnectionString)},
-                {"Etcd", stringSupplier(() -> "etcd:" + getEtcdClusterConnectString())},
-                {"MockZooKeeper", stringSupplier(() -> mockZkUrl)},
+                {"ZooKeeper", providerUrlSupplier(() -> zksConnectionString)},
+                {"Memory", providerUrlSupplier(() -> memoryConnectionString)},
+                {"RocksDB", providerUrlSupplier(() -> rocksdbConnectionString)},
+                {"Etcd", providerUrlSupplier(() -> "etcd:" + getEtcdClusterConnectString(), "etcd:...")},
+                {"MockZooKeeper", providerUrlSupplier(() -> mockZkUrl)},
         };
     }
 
@@ -165,16 +166,29 @@ public abstract class BaseMetadataStoreTest extends TestRetrySupport {
         return etcdCluster.clientEndpoints().stream().map(URI::toString).collect(Collectors.joining(","));
     }
 
-    public static Supplier<String> stringSupplier(Supplier<String> supplier) {
-        return new StringSupplier(supplier);
+    private static Supplier<String> providerUrlSupplier(Supplier<String> supplier) {
+        return new ProviderUrlSupplier(supplier);
+    }
+
+    // Use this method to provide a custom toString value for the Supplier<String>. Use this when Testcontainers is used
+    // so that a toString call doesn't eagerly trigger container initialization which could cause a deadlock
+    // with Gradle Develocity Maven Extension.
+    private static Supplier<String> providerUrlSupplier(Supplier<String> supplier, String toStringValue) {
+        return new ProviderUrlSupplier(supplier, Optional.ofNullable(toStringValue));
     }
 
     // Implements toString() so that the test name is more descriptive
-    private static class StringSupplier implements Supplier<String> {
+    private static class ProviderUrlSupplier implements Supplier<String> {
         private final Supplier<String> supplier;
+        private final Optional<String> toStringValue;
+
+        ProviderUrlSupplier(Supplier<String> supplier) {
+            this(supplier, Optional.empty());
+        }
 
-        public StringSupplier(Supplier<String> supplier) {
+        ProviderUrlSupplier(Supplier<String> supplier, Optional<String> toStringValue) {
             this.supplier = supplier;
+            this.toStringValue = toStringValue;
         }
 
         @Override
@@ -184,7 +198,9 @@ public abstract class BaseMetadataStoreTest extends TestRetrySupport {
 
         @Override
         public String toString() {
-            return get();
+            // toStringValue is used to prevent deadlocks which could occur if toString method call eagerly triggers
+            // Testcontainers initialization. This is the case when Gradle Develocity Maven Extension is used.
+            return toStringValue.orElseGet(this::get);
         }
     }