Skip to content

Commit 28c6f94

Browse files
committed
Merge branch 'master' into master-vuminhkh
* master: Update CHANGELOG.md issue #349
2 parents 90f4aba + c58d24a commit 28c6f94

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Change Log
22
===
33
Latest SNAPSHOT version
44
---
5+
* [#350] (https://github.com/docker-java/docker-java/pull/350) Remove ServiceLoader logic
56
* [#344] (https://github.com/docker-java/docker-java/pull/344) Implement equals/hashCode for Filters
67
* [#335] (https://github.com/docker-java/docker-java/pull/335) Improve backward-compatibility support for older API versions
78
* [#333] (https://github.com/docker-java/docker-java/pull/333) Adding support for withPidMode

src/main/java/com/github/dockerjava/core/DockerClientBuilder.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
package com.github.dockerjava.core;
22

3-
import java.util.Iterator;
4-
import java.util.ServiceLoader;
5-
63
import com.github.dockerjava.api.DockerClient;
74
import com.github.dockerjava.api.command.DockerCmdExecFactory;
85
import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;
6+
import com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl;
97

108
public class DockerClientBuilder {
119

12-
private static Class<? extends DockerCmdExecFactory> factoryClass;
13-
14-
private static ServiceLoader<DockerCmdExecFactory> serviceLoader = ServiceLoader.load(DockerCmdExecFactory.class);
15-
16-
static {
17-
serviceLoader.reload();
18-
Iterator<DockerCmdExecFactory> iterator = serviceLoader.iterator();
19-
if (iterator.hasNext()) {
20-
factoryClass = iterator.next().getClass();
21-
}
22-
}
23-
2410
private DockerClientImpl dockerClient = null;
2511

2612
private DockerCmdExecFactory dockerCmdExecFactory = null;
@@ -46,28 +32,14 @@ public static DockerClientBuilder getInstance(String serverUrl) {
4632
}
4733

4834
public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
49-
if (factoryClass == null) {
50-
throw new RuntimeException("Fatal: Can't find any implementation of '"
51-
+ DockerCmdExecFactory.class.getName() + "' in the current classpath.");
52-
}
53-
54-
try {
55-
return factoryClass.newInstance();
56-
} catch (InstantiationException | IllegalAccessException e) {
57-
throw new RuntimeException("Fatal: Can't create new instance of '" + factoryClass.getName() + "'");
58-
}
35+
return new DockerCmdExecFactoryImpl();
5936
}
6037

6138
public DockerClientBuilder withDockerCmdExecFactory(DockerCmdExecFactory dockerCmdExecFactory) {
6239
this.dockerCmdExecFactory = dockerCmdExecFactory;
6340
return this;
6441
}
6542

66-
public DockerClientBuilder withServiceLoaderClassLoader(ClassLoader classLoader) {
67-
serviceLoader = ServiceLoader.load(DockerCmdExecFactory.class, classLoader);
68-
return this;
69-
}
70-
7143
public DockerClient build() {
7244
if (dockerCmdExecFactory != null) {
7345
dockerClient.withDockerCmdExecFactory(dockerCmdExecFactory);

0 commit comments

Comments
 (0)