Skip to content

Commit 1a43ec7

Browse files
committed
[improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (#24004)
(cherry picked from commit 35c9fec)
1 parent 85daa34 commit 1a43ec7

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.File;
2727
import java.net.URI;
2828
import java.util.Arrays;
29+
import java.util.Optional;
2930
import java.util.Set;
3031
import java.util.UUID;
3132
import java.util.concurrent.CompletionException;
@@ -136,12 +137,12 @@ private Object[][] allImplementations() {
136137
// The new connection string won't be available to the test method unless a
137138
// Supplier<String> lambda is used for providing the value.
138139
return new Object[][]{
139-
{"ZooKeeper", stringSupplier(() -> zksConnectionString)},
140-
{"Memory", stringSupplier(() -> memoryConnectionString)},
141-
{"RocksDB", stringSupplier(() -> rocksdbConnectionString)},
142-
{"Etcd", stringSupplier(() -> "etcd:" + getEtcdClusterConnectString())},
143-
{"Oxia", stringSupplier(() -> "oxia://" + getOxiaServerConnectString())},
144-
{"MockZooKeeper", stringSupplier(() -> mockZkUrl)},
140+
{"ZooKeeper", providerUrlSupplier(() -> zksConnectionString)},
141+
{"Memory", providerUrlSupplier(() -> memoryConnectionString)},
142+
{"RocksDB", providerUrlSupplier(() -> rocksdbConnectionString)},
143+
{"Etcd", providerUrlSupplier(() -> "etcd:" + getEtcdClusterConnectString(), "etcd:...")},
144+
{"Oxia", providerUrlSupplier(() -> "oxia://" + getOxiaServerConnectString(), "oxia://...")},
145+
{"MockZooKeeper", providerUrlSupplier(() -> mockZkUrl)},
145146
};
146147
}
147148

@@ -185,16 +186,29 @@ private synchronized String getEtcdClusterConnectString() {
185186
return etcdCluster.clientEndpoints().stream().map(URI::toString).collect(Collectors.joining(","));
186187
}
187188

188-
public static Supplier<String> stringSupplier(Supplier<String> supplier) {
189-
return new StringSupplier(supplier);
189+
private static Supplier<String> providerUrlSupplier(Supplier<String> supplier) {
190+
return new ProviderUrlSupplier(supplier);
191+
}
192+
193+
// Use this method to provide a custom toString value for the Supplier<String>. Use this when Testcontainers is used
194+
// so that a toString call doesn't eagerly trigger container initialization which could cause a deadlock
195+
// with Gradle Develocity Maven Extension.
196+
private static Supplier<String> providerUrlSupplier(Supplier<String> supplier, String toStringValue) {
197+
return new ProviderUrlSupplier(supplier, Optional.ofNullable(toStringValue));
190198
}
191199

192200
// Implements toString() so that the test name is more descriptive
193-
private static class StringSupplier implements Supplier<String> {
201+
private static class ProviderUrlSupplier implements Supplier<String> {
194202
private final Supplier<String> supplier;
203+
private final Optional<String> toStringValue;
204+
205+
ProviderUrlSupplier(Supplier<String> supplier) {
206+
this(supplier, Optional.empty());
207+
}
195208

196-
public StringSupplier(Supplier<String> supplier) {
209+
ProviderUrlSupplier(Supplier<String> supplier, Optional<String> toStringValue) {
197210
this.supplier = supplier;
211+
this.toStringValue = toStringValue;
198212
}
199213

200214
@Override
@@ -204,7 +218,9 @@ public String get() {
204218

205219
@Override
206220
public String toString() {
207-
return get();
221+
// toStringValue is used to prevent deadlocks which could occur if toString method call eagerly triggers
222+
// Testcontainers initialization. This is the case when Gradle Develocity Maven Extension is used.
223+
return toStringValue.orElseGet(this::get);
208224
}
209225
}
210226

0 commit comments

Comments
 (0)