Skip to content

Commit 877aff5

Browse files
committed
Revert "Revert "[improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (apache#24004)""
This reverts commit 2e6abac.
1 parent 875df13 commit 877aff5

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

.mvn/extensions.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<extension>
2525
<groupId>com.gradle</groupId>
2626
<artifactId>develocity-maven-extension</artifactId>
27-
<version>1.22.2</version>
27+
<version>1.23.1</version>
2828
</extension>
2929
<extension>
3030
<groupId>com.gradle</groupId>

pulsar-metadata/src/test/java/org/apache/pulsar/metadata/BaseMetadataStoreTest.java

+26-10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.File;
2626
import java.net.URI;
2727
import java.util.Arrays;
28+
import java.util.Optional;
2829
import java.util.Set;
2930
import java.util.UUID;
3031
import java.util.concurrent.CompletionException;
@@ -128,11 +129,11 @@ private Object[][] allImplementations() {
128129
// The new connection string won't be available to the test method unless a
129130
// Supplier<String> lambda is used for providing the value.
130131
return new Object[][]{
131-
{"ZooKeeper", stringSupplier(() -> zksConnectionString)},
132-
{"Memory", stringSupplier(() -> memoryConnectionString)},
133-
{"RocksDB", stringSupplier(() -> rocksdbConnectionString)},
134-
{"Etcd", stringSupplier(() -> "etcd:" + getEtcdClusterConnectString())},
135-
{"MockZooKeeper", stringSupplier(() -> mockZkUrl)},
132+
{"ZooKeeper", providerUrlSupplier(() -> zksConnectionString)},
133+
{"Memory", providerUrlSupplier(() -> memoryConnectionString)},
134+
{"RocksDB", providerUrlSupplier(() -> rocksdbConnectionString)},
135+
{"Etcd", providerUrlSupplier(() -> "etcd:" + getEtcdClusterConnectString(), "etcd:...")},
136+
{"MockZooKeeper", providerUrlSupplier(() -> mockZkUrl)},
136137
};
137138
}
138139

@@ -165,16 +166,29 @@ private synchronized String getEtcdClusterConnectString() {
165166
return etcdCluster.clientEndpoints().stream().map(URI::toString).collect(Collectors.joining(","));
166167
}
167168

168-
public static Supplier<String> stringSupplier(Supplier<String> supplier) {
169-
return new StringSupplier(supplier);
169+
private static Supplier<String> providerUrlSupplier(Supplier<String> supplier) {
170+
return new ProviderUrlSupplier(supplier);
171+
}
172+
173+
// Use this method to provide a custom toString value for the Supplier<String>. Use this when Testcontainers is used
174+
// so that a toString call doesn't eagerly trigger container initialization which could cause a deadlock
175+
// with Gradle Develocity Maven Extension.
176+
private static Supplier<String> providerUrlSupplier(Supplier<String> supplier, String toStringValue) {
177+
return new ProviderUrlSupplier(supplier, Optional.ofNullable(toStringValue));
170178
}
171179

172180
// Implements toString() so that the test name is more descriptive
173-
private static class StringSupplier implements Supplier<String> {
181+
private static class ProviderUrlSupplier implements Supplier<String> {
174182
private final Supplier<String> supplier;
183+
private final Optional<String> toStringValue;
184+
185+
ProviderUrlSupplier(Supplier<String> supplier) {
186+
this(supplier, Optional.empty());
187+
}
175188

176-
public StringSupplier(Supplier<String> supplier) {
189+
ProviderUrlSupplier(Supplier<String> supplier, Optional<String> toStringValue) {
177190
this.supplier = supplier;
191+
this.toStringValue = toStringValue;
178192
}
179193

180194
@Override
@@ -184,7 +198,9 @@ public String get() {
184198

185199
@Override
186200
public String toString() {
187-
return get();
201+
// toStringValue is used to prevent deadlocks which could occur if toString method call eagerly triggers
202+
// Testcontainers initialization. This is the case when Gradle Develocity Maven Extension is used.
203+
return toStringValue.orElseGet(this::get);
188204
}
189205
}
190206

0 commit comments

Comments
 (0)