@@ -11,36 +11,28 @@ public class DockerClientBuilder {
1111 private static ServiceLoader <DockerCmdExecFactory > serviceLoader = ServiceLoader .load (DockerCmdExecFactory .class );
1212
1313 private DockerClientImpl dockerClient = null ;
14+ private DockerCmdExecFactory dockerCmdExecFactory = null ;
1415
1516 private DockerClientBuilder (DockerClientImpl dockerClient ) {
1617 this .dockerClient = dockerClient ;
1718 }
1819
1920 public static DockerClientBuilder getInstance () {
20- return new DockerClientBuilder (withDefaultDockerCmdExecFactory ( DockerClientImpl .getInstance () ));
21+ return new DockerClientBuilder (DockerClientImpl .getInstance ());
2122 }
2223
2324 public static DockerClientBuilder getInstance (DockerClientConfigBuilder dockerClientConfigBuilder ) {
2425 return getInstance (dockerClientConfigBuilder .build ());
2526 }
2627
2728 public static DockerClientBuilder getInstance (DockerClientConfig dockerClientConfig ) {
28- return new DockerClientBuilder (withDefaultDockerCmdExecFactory ( DockerClientImpl
29- .getInstance (dockerClientConfig ))) ;
29+ return new DockerClientBuilder (DockerClientImpl
30+ .getInstance (dockerClientConfig ));
3031 }
3132
3233 public static DockerClientBuilder getInstance (String serverUrl ) {
33- return new DockerClientBuilder (withDefaultDockerCmdExecFactory (DockerClientImpl
34- .getInstance (serverUrl )));
35- }
36-
37- private static DockerClientImpl withDefaultDockerCmdExecFactory (
38- DockerClientImpl dockerClient ) {
39-
40- DockerCmdExecFactory dockerCmdExecFactory = getDefaultDockerCmdExecFactory ();
41-
42- return dockerClient
43- .withDockerCmdExecFactory (dockerCmdExecFactory );
34+ return new DockerClientBuilder (DockerClientImpl
35+ .getInstance (serverUrl ));
4436 }
4537
4638 public static DockerCmdExecFactory getDefaultDockerCmdExecFactory () {
@@ -53,12 +45,18 @@ public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
5345
5446 public DockerClientBuilder withDockerCmdExecFactory (
5547 DockerCmdExecFactory dockerCmdExecFactory ) {
56- dockerClient = dockerClient
57- .withDockerCmdExecFactory (dockerCmdExecFactory );
48+ this .dockerCmdExecFactory = dockerCmdExecFactory ;
5849 return this ;
5950 }
6051
6152 public DockerClient build () {
53+ if (dockerCmdExecFactory != null ) {
54+ dockerClient .withDockerCmdExecFactory (dockerCmdExecFactory );
55+ }
56+ else {
57+ dockerClient .withDockerCmdExecFactory (getDefaultDockerCmdExecFactory ());
58+ }
59+
6260 return dockerClient ;
6361 }
6462}
0 commit comments