Skip to content

Commit

Permalink
[improve][ci] Upgrade Gradle Develocity Maven Extension to 1.23.1 (ap…
Browse files Browse the repository at this point in the history
…ache#24004)

(cherry picked from commit 35c9fec)
(cherry picked from commit 49ca5d6)
  • Loading branch information
lhotari authored and nikhil-ctds committed Feb 28, 2025
1 parent 2607a49 commit 0d3df69
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -128,11 +129,11 @@ private Object[][] allImplementations() {
// 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)},
};
}

Expand Down Expand Up @@ -165,16 +166,29 @@ private synchronized String getEtcdClusterConnectString() {
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
Expand All @@ -184,7 +198,9 @@ public String get() {

@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);
}
}

Expand Down

0 comments on commit 0d3df69

Please sign in to comment.