Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/main/java/com/github/dockerjava/core/DockerClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class DockerClientConfig implements Serializable {
private static final String DOCKER_IO_EMAIL_PROPERTY = "docker.io.email";
private static final String DOCKER_IO_SERVER_ADDRESS_PROPERTY = "docker.io.serverAddress";
private static final String DOCKER_IO_READ_TIMEOUT_PROPERTY = "docker.io.readTimeout";
private static final String DOCKER_IO_CONNECT_TIMEOUT_PROPERTY = "docker.io.connectimeout";
// this is really confusing, as there are two ways to spell it
private static final String DOCKER_IO_ENABLE_LOGGING_FILTER_PROPERTY = "docker.io.enableLoggingFilter";
private static final String DOCKER_IO_FOLLOW_REDIRECTS_FILTER_PROPERTY = "docker.io.followRedirectsFilter";
Expand All @@ -54,6 +55,7 @@ public class DockerClientConfig implements Serializable {
m.put("DOCKER_EMAIL", DOCKER_IO_EMAIL_PROPERTY);
m.put("DOCKER_SERVER_ADDRESS", DOCKER_IO_SERVER_ADDRESS_PROPERTY);
m.put("DOCKER_READ_TIMEOUT", DOCKER_IO_READ_TIMEOUT_PROPERTY);
m.put("DOCKER_CONNECT_TIMEOUT", DOCKER_IO_CONNECT_TIMEOUT_PROPERTY);
m.put("DOCKER_LOGGING_FILTER_ENABLED", DOCKER_IO_ENABLE_LOGGING_FILTER_PROPERTY);
m.put("DOCKER_FOLLOW_REDIRECTS_FILTER_ENABLED", DOCKER_IO_FOLLOW_REDIRECTS_FILTER_PROPERTY);
m.put(DOCKER_CERT_PATH_PROPERTY, DOCKER_IO_DOCKER_CERT_PATH_PROPERTY);
Expand All @@ -64,7 +66,7 @@ public class DockerClientConfig implements Serializable {
private static final String DOCKER_IO_PROPERTIES_PROPERTY = "docker.io.properties";
private URI uri;
private final String version, username, password, email, serverAddress, dockerCfgPath;
private final Integer readTimeout;
private final Integer readTimeout, connectTimeout;
private final boolean loggingFilterEnabled;
private final boolean followRedirectsFilterEnabled;
private final SSLConfig sslConfig;
Expand All @@ -73,7 +75,7 @@ public class DockerClientConfig implements Serializable {
private final Integer maxPerRouteConnections;

DockerClientConfig(URI uri, String version, String username, String password, String email, String serverAddress,
String dockerCfgPath, Integer readTimeout, boolean loggingFilterEnabled, boolean followRedirectsFilterEnabled,
String dockerCfgPath, Integer readTimeout, Integer connectTimeout, boolean loggingFilterEnabled, boolean followRedirectsFilterEnabled,
SSLConfig sslConfig, Integer maxTotalConns, Integer maxPerRouteConns) {
this.uri = uri;
this.version = version;
Expand All @@ -83,6 +85,7 @@ public class DockerClientConfig implements Serializable {
this.serverAddress = serverAddress;
this.dockerCfgPath = dockerCfgPath;
this.readTimeout = readTimeout;
this.connectTimeout = connectTimeout;
this.loggingFilterEnabled = loggingFilterEnabled;
this.followRedirectsFilterEnabled = followRedirectsFilterEnabled;
this.sslConfig = sslConfig;
Expand Down Expand Up @@ -186,6 +189,7 @@ private static Properties overrideDockerPropertiesWithSystemProperties(Propertie
DOCKER_IO_EMAIL_PROPERTY,
DOCKER_IO_SERVER_ADDRESS_PROPERTY,
DOCKER_IO_READ_TIMEOUT_PROPERTY,
DOCKER_IO_CONNECT_TIMEOUT_PROPERTY,
DOCKER_IO_ENABLE_LOGGING_FILTER_PROPERTY,
DOCKER_IO_FOLLOW_REDIRECTS_FILTER_PROPERTY,
DOCKER_IO_DOCKER_CERT_PATH_PROPERTY,
Expand Down Expand Up @@ -245,6 +249,10 @@ public Integer getReadTimeout() {
return readTimeout;
}

public Integer getConnectTimeout() {
return connectTimeout;
}

public boolean isLoggingFilterEnabled() {
return loggingFilterEnabled;
}
Expand Down Expand Up @@ -344,6 +352,7 @@ public boolean equals(Object o) {
if (email != null ? !email.equals(that.email) : that.email != null) return false;
if (password != null ? !password.equals(that.password) : that.password != null) return false;
if (readTimeout != null ? !readTimeout.equals(that.readTimeout) : that.readTimeout != null) return false;
if (connectTimeout != null ? !connectTimeout.equals(that.connectTimeout) : that.connectTimeout != null) return false;
if (serverAddress != null ? !serverAddress.equals(that.serverAddress) : that.serverAddress != null)
return false;
if (uri != null ? !uri.equals(that.uri) : that.uri != null) return false;
Expand All @@ -364,6 +373,7 @@ public int hashCode() {
result = 31 * result + (dockerCfgPath != null ? dockerCfgPath.hashCode() : 0);
result = 31 * result + (sslConfig != null ? sslConfig.hashCode() : 0);
result = 31 * result + (readTimeout != null ? readTimeout.hashCode() : 0);
result = 31 * result + (connectTimeout != null ? connectTimeout.hashCode() : 0);
result = 31 * result + (loggingFilterEnabled ? 1 : 0);
return result;
}
Expand All @@ -380,6 +390,7 @@ public String toString() {
", dockerCfgPath='" + dockerCfgPath + '\'' +
", sslConfig='" + sslConfig + '\'' +
", readTimeout=" + readTimeout +
", connectTimeout=" + connectTimeout +
", loggingFilterEnabled=" + loggingFilterEnabled +
", followRedirectsFilterEnabled=" + followRedirectsFilterEnabled +
'}';
Expand All @@ -388,7 +399,7 @@ public String toString() {
public static class DockerClientConfigBuilder {
private URI uri;
private String version, username, password, email, serverAddress, dockerCfgPath;
private Integer readTimeout, maxTotalConnections, maxPerRouteConnections;
private Integer readTimeout, connectTimeout, maxTotalConnections, maxPerRouteConnections;
private boolean loggingFilterEnabled, followRedirectsFilterEnabled;
private SSLConfig sslConfig;

Expand All @@ -406,6 +417,7 @@ public DockerClientConfigBuilder withProperties(Properties p) {
.withEmail(p.getProperty(DOCKER_IO_EMAIL_PROPERTY))
.withServerAddress(p.getProperty(DOCKER_IO_SERVER_ADDRESS_PROPERTY))
.withReadTimeout(Integer.valueOf(p.getProperty(DOCKER_IO_READ_TIMEOUT_PROPERTY, "0")))
.withConnectTimeout(Integer.valueOf(p.getProperty(DOCKER_IO_CONNECT_TIMEOUT_PROPERTY, "0")))
.withLoggingFilter(Boolean.valueOf(p.getProperty(DOCKER_IO_ENABLE_LOGGING_FILTER_PROPERTY, "true")))
.withFollowRedirectsFilter(Boolean.valueOf(p.getProperty(DOCKER_IO_FOLLOW_REDIRECTS_FILTER_PROPERTY, "false")))
.withDockerCertPath(p.getProperty(DOCKER_IO_DOCKER_CERT_PATH_PROPERTY))
Expand Down Expand Up @@ -456,6 +468,11 @@ public final DockerClientConfigBuilder withReadTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
return this;
}

public final DockerClientConfigBuilder withConnectTimeout(Integer connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}

public final DockerClientConfigBuilder withMaxTotalConnections(Integer maxTotalConnections) {
this.maxTotalConnections = maxTotalConnections;
Expand Down Expand Up @@ -505,6 +522,7 @@ public DockerClientConfig build() {
serverAddress,
dockerCfgPath,
readTimeout,
connectTimeout,
loggingFilterEnabled,
followRedirectsFilterEnabled,
sslConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public void init(DockerClientConfig dockerClientConfig) {
clientConfig.property(ClientProperties.READ_TIMEOUT, readTimeout);
}

if (dockerClientConfig.getConnectTimeout() != null) {
int connectTimeout = dockerClientConfig.getConnectTimeout();
clientConfig.property(ClientProperties.CONNECT_TIMEOUT, connectTimeout);
}

URI originalUri = dockerClientConfig.getUri();

SSLContext sslContext = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DockerClientConfigTest {
public static final DockerClientConfig EXAMPLE_CONFIG = newExampleConfig();

private static DockerClientConfig newExampleConfig() {
return new DockerClientConfig(URI.create("http://foo"), "bar", "baz", "qux", "blam", "wham", "flam", 877, false, false, new LocalDirectorySSLConfig("flim"), 20, 2);
return new DockerClientConfig(URI.create("http://foo"), "bar", "baz", "qux", "blam", "wham", "flam", 877, 999, false, false, new LocalDirectorySSLConfig("flim"), 20, 2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DockerClientImplTest {
@Test
public void configuredInstanceAuthConfig() throws Exception {
// given a config with null serverAddress
DockerClientConfig dockerClientConfig = new DockerClientConfig(null, null, "", "", "", null, null, 0, false, false, null, 20, 2);
DockerClientConfig dockerClientConfig = new DockerClientConfig(null, null, "", "", "", null, null, 0, 0, false, false, null, 20, 2);
DockerClientImpl dockerClient = DockerClientImpl.getInstance(dockerClientConfig);

// when we get the auth config
Expand Down