Skip to content

Commit 5e88d74

Browse files
authored
Update to docker-java 3.2.12 (#4459)
* Try `docker-java` 3.2.12 * use shaded configuration * Update build.gradle
1 parent 79b064b commit 5e88d74

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

core/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ dependencies {
7777

7878
shaded 'org.awaitility:awaitility:4.1.0'
7979

80-
api "com.github.docker-java:docker-java-api:3.2.11"
80+
shaded platform('com.github.docker-java:docker-java-bom:3.2.12')
8181

82-
shaded ('com.github.docker-java:docker-java-core:3.2.11') {
82+
api "com.github.docker-java:docker-java-api"
83+
84+
shaded ('com.github.docker-java:docker-java-core') {
8385
exclude(group: 'com.github.docker-java', module: 'docker-java-api')
8486
exclude(group: 'com.github.docker-java', module: 'docker-java-transport')
8587
exclude(group: 'com.fasterxml.jackson.core', module: 'jackson-annotations')
@@ -88,13 +90,13 @@ dependencies {
8890
exclude(group: 'org.apache.commons', module: 'commons-compress')
8991
}
9092

91-
shaded ('com.github.docker-java:docker-java-transport-okhttp:3.2.11') {
93+
shaded ('com.github.docker-java:docker-java-transport-okhttp') {
9294
exclude(group: 'com.github.docker-java', module: 'docker-java-core')
9395
exclude(group: 'net.java.dev.jna')
9496
exclude(group: 'org.slf4j')
9597
}
9698

97-
api 'com.github.docker-java:docker-java-transport-zerodep:3.2.11'
99+
api 'com.github.docker-java:docker-java-transport-zerodep'
98100

99101
shaded "org.yaml:snakeyaml:1.29"
100102

core/src/main/java/org/testcontainers/DockerClientFactory.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.testcontainers;
22

33
import com.github.dockerjava.api.DockerClient;
4+
import com.github.dockerjava.api.DockerClientDelegate;
45
import com.github.dockerjava.api.async.ResultCallback;
56
import com.github.dockerjava.api.command.CreateContainerCmd;
67
import com.github.dockerjava.api.command.PullImageCmd;
@@ -94,7 +95,17 @@ public class DockerClientFactory {
9495
}
9596

9697
public static DockerClient lazyClient() {
97-
return LazyDockerClient.INSTANCE;
98+
return new DockerClientDelegate() {
99+
@Override
100+
protected DockerClient getDockerClient() {
101+
return instance().client();
102+
}
103+
104+
@Override
105+
public String toString() {
106+
return "LazyDockerClient";
107+
}
108+
};
98109
}
99110

100111
/**
@@ -177,7 +188,11 @@ public DockerClient client() {
177188
final DockerClientProviderStrategy strategy = getOrInitializeStrategy();
178189

179190
log.info("Docker host IP address is {}", strategy.getDockerHostIpAddress());
180-
final DockerClient client = new DelegatingDockerClient(strategy.getDockerClient()) {
191+
final DockerClient client = new DockerClientDelegate() {
192+
193+
@Getter
194+
final DockerClient dockerClient = strategy.getDockerClient();
195+
181196
@Override
182197
public void close() {
183198
throw new IllegalStateException("You should never close the global DockerClient!");

core/src/main/java/org/testcontainers/LazyDockerClient.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

core/src/main/java/org/testcontainers/dockerclient/AuthDelegatingDockerClientConfig.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.github.dockerjava.api.model.AuthConfig;
44
import com.github.dockerjava.core.DockerClientConfig;
5-
import lombok.experimental.Delegate;
5+
import com.github.dockerjava.core.DockerClientConfigDelegate;
66
import lombok.extern.slf4j.Slf4j;
77
import org.testcontainers.utility.DockerImageName;
88
import org.testcontainers.utility.RegistryAuthLocator;
@@ -18,20 +18,18 @@
1818
* TODO move to docker-java
1919
*/
2020
@Slf4j
21-
class AuthDelegatingDockerClientConfig implements DockerClientConfig {
22-
23-
@Delegate(excludes = DelegateExclusions.class)
24-
private DockerClientConfig delegate;
21+
class AuthDelegatingDockerClientConfig extends DockerClientConfigDelegate {
2522

2623
public AuthDelegatingDockerClientConfig(DockerClientConfig delegate) {
27-
this.delegate = delegate;
24+
super(delegate);
2825
}
2926

27+
@Override
3028
public AuthConfig effectiveAuthConfig(String imageName) {
3129
// allow docker-java auth config to be used as a fallback
3230
AuthConfig fallbackAuthConfig;
3331
try {
34-
fallbackAuthConfig = delegate.effectiveAuthConfig(imageName);
32+
fallbackAuthConfig = super.effectiveAuthConfig(imageName);
3533
} catch (Exception e) {
3634
log.debug("Delegate call to effectiveAuthConfig failed with cause: '{}'. " +
3735
"Resolution of auth config will continue using RegistryAuthLocator.",
@@ -47,8 +45,4 @@ public AuthConfig effectiveAuthConfig(String imageName) {
4745
log.debug("Effective auth config [{}]", toSafeString(effectiveAuthConfig));
4846
return effectiveAuthConfig;
4947
}
50-
51-
private interface DelegateExclusions {
52-
AuthConfig effectiveAuthConfig(String imageName);
53-
}
5448
}

0 commit comments

Comments
 (0)