chore(core): do not expect default DockerCmdExecFactory service · docker-java/docker-java@74caed5

File tree

1 file changed

lines changed

  • src/main/java/com/github/dockerjava/core

1 file changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -16,12 +16,9 @@ public class DockerClientBuilder {

1616

static {

1717

serviceLoader.reload();

1818

Iterator<DockerCmdExecFactory> iterator = serviceLoader.iterator();

19-

if (!iterator.hasNext()) {

20-

throw new RuntimeException("Fatal: Can't find any implementation of '"

21-

+ DockerCmdExecFactory.class.getName() + "' in the current classpath.");

19+

if (iterator.hasNext()) {

20+

factoryClass = iterator.next().getClass();

2221

}

23-
24-

factoryClass = iterator.next().getClass();

2522

}

2623
2724

private DockerClientImpl dockerClient = null;

@@ -49,6 +46,11 @@ public static DockerClientBuilder getInstance(String serverUrl) {

4946

}

5047
5148

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+
5254

try {

5355

return factoryClass.newInstance();

5456

} catch (InstantiationException | IllegalAccessException e) {