<commit_before>package com.github.dockerjava.core;

import java.util.ServiceLoader;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.DockerCmdExecFactory;
import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;

public class DockerClientBuilder {
	
	private static ServiceLoader<DockerCmdExecFactory> serviceLoader = ServiceLoader.load(DockerCmdExecFactory.class);

	private DockerClientImpl dockerClient = null;

	private DockerClientBuilder(DockerClientImpl dockerClient) {
		this.dockerClient = dockerClient;
	}

	public static DockerClientBuilder getInstance() {
		return new DockerClientBuilder(withDefaultDockerCmdExecFactory(DockerClientImpl.getInstance()));
	}
	
	public static DockerClientBuilder getInstance(DockerClientConfigBuilder dockerClientConfigBuilder) {
		return getInstance(dockerClientConfigBuilder.build());
	}

	public static DockerClientBuilder getInstance(DockerClientConfig dockerClientConfig) {
		return new DockerClientBuilder(withDefaultDockerCmdExecFactory(DockerClientImpl
				.getInstance(dockerClientConfig)));
	}

	public static DockerClientBuilder getInstance(String serverUrl) {
		return new DockerClientBuilder(withDefaultDockerCmdExecFactory(DockerClientImpl
				.getInstance(serverUrl)));
	}

	private static DockerClientImpl withDefaultDockerCmdExecFactory(
			DockerClientImpl dockerClient) {
		
		DockerCmdExecFactory dockerCmdExecFactory = getDefaultDockerCmdExecFactory();
		
		return dockerClient
				.withDockerCmdExecFactory(dockerCmdExecFactory);
	}

	public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
		if(!serviceLoader.iterator().hasNext()) {
			throw new RuntimeException("Fatal: Can't find any implementation of '" + DockerCmdExecFactory.class.getName() +  "' in the current classpath.");
		}
		
		return serviceLoader.iterator().next();
	}

	public DockerClientBuilder withDockerCmdExecFactory(
			DockerCmdExecFactory dockerCmdExecFactory) {
		dockerClient = dockerClient
				.withDockerCmdExecFactory(dockerCmdExecFactory);
		return this;
	}

	public DockerClient build() {
		return dockerClient;
	}
}<commit_msg>Allow for custom implementations of DockerCmdExecFactory to be specified without attempting to load default<commit_after>package com.github.dockerjava.core;

import java.util.ServiceLoader;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.DockerCmdExecFactory;
import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;

public class DockerClientBuilder {
	
	private static ServiceLoader<DockerCmdExecFactory> serviceLoader = ServiceLoader.load(DockerCmdExecFactory.class);

	private DockerClientImpl dockerClient = null;
	private DockerCmdExecFactory dockerCmdExecFactory = null;

	private DockerClientBuilder(DockerClientImpl dockerClient) {
		this.dockerClient = dockerClient;
	}

	public static DockerClientBuilder getInstance() {
		return new DockerClientBuilder(DockerClientImpl.getInstance());
	}
	
	public static DockerClientBuilder getInstance(DockerClientConfigBuilder dockerClientConfigBuilder) {
		return getInstance(dockerClientConfigBuilder.build());
	}

	public static DockerClientBuilder getInstance(DockerClientConfig dockerClientConfig) {
		return new DockerClientBuilder(DockerClientImpl
				.getInstance(dockerClientConfig));
	}

	public static DockerClientBuilder getInstance(String serverUrl) {
		return new DockerClientBuilder(DockerClientImpl
				.getInstance(serverUrl));
	}

	public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
		if(!serviceLoader.iterator().hasNext()) {
			throw new RuntimeException("Fatal: Can't find any implementation of '" + DockerCmdExecFactory.class.getName() +  "' in the current classpath.");
		}
		
		return serviceLoader.iterator().next();
	}

	public DockerClientBuilder withDockerCmdExecFactory(
			DockerCmdExecFactory dockerCmdExecFactory) {
		this.dockerCmdExecFactory = dockerCmdExecFactory;
		return this;
	}

	public DockerClient build() {
	        if(dockerCmdExecFactory != null) {
	            dockerClient.withDockerCmdExecFactory(dockerCmdExecFactory);
	        }
	        else {
	            dockerClient.withDockerCmdExecFactory(getDefaultDockerCmdExecFactory());
	        }
	        
		return dockerClient;
	}
}
{'fraction_non_alphanumeric': 0.0737134909596662, 'fraction_numerical': 0.0, 'mean_word_length': 6.203672787979967, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7249691', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1102, 'n_words': 221}