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
77 changes: 49 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,35 @@
<jdk.source>1.7</jdk.source>
<jdk.target>1.7</jdk.target>

<jersey.version>2.11</jersey.version>
<jersey.version>2.23.1</jersey.version>
<jackson-jaxrs.version>2.6.4</jackson-jaxrs.version>
<httpclient.version>4.3.1</httpclient.version>
<commons-compress.version>1.5</commons-compress.version>
<commons-codec.version>1.8</commons-codec.version>
<commons-io.version>2.3</commons-io.version>
<httpclient.version>4.5</httpclient.version><!-- 4.5.1-4.5.2 broken -->
<commons-compress.version>1.12</commons-compress.version>
<commons-codec.version>1.10</commons-codec.version>
<commons-io.version>2.5</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<slf4j-api.version>1.7.5</slf4j-api.version>
<slf4j-api.version>1.7.21</slf4j-api.version>

<bouncycastle.version>1.51</bouncycastle.version>
<unix-socket-factory.version>2015-01-27T15-02-14</unix-socket-factory.version>
<guava.version>18.0</guava.version>
<bouncycastle.version>1.54</bouncycastle.version>
<unix-socket-factory.version>2016-04-06T22-21-19</unix-socket-factory.version>
<guava.version>19.0</guava.version>

<!-- test dependencies -->
<logback.version>1.1.0</logback.version>
<testng.version>6.1.1</testng.version>
<netty.version>4.1.0.CR3</netty.version>
<logback.version>1.1.7</logback.version>
<testng.version>6.9.10</testng.version>
<netty.version>4.1.1.Final</netty.version>
<hamcrest.library.version>1.3</hamcrest.library.version>
<hamcrest.jpa-matchers>1.6</hamcrest.jpa-matchers>
<hamcrest.jpa-matchers>1.8</hamcrest.jpa-matchers>
<lambdaj.version>2.3.3</lambdaj.version>
<mockito.version>1.10.19</mockito.version>


<maven-jar-plugin.version>2.2</maven-jar-plugin.version>
<maven-compiler-plugin.version>2.3.1</maven-compiler-plugin.version>
<maven-release-plugin.version>2.3.1</maven-release-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
<maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
</properties>

<dependencies>
Expand All @@ -89,6 +89,11 @@
<artifactId>jersey-apache-connector</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand All @@ -99,10 +104,20 @@
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>de.gesellix</groupId>-->
<!--<artifactId>unix-socket-factory</artifactId>-->
<!--<version>${unix-socket-factory.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-common</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>de.gesellix</groupId>
<artifactId>unix-socket-factory</artifactId>
<version>${unix-socket-factory.version}</version>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-native-common</artifactId>
<version>2.0.4</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -133,7 +148,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.12</version>
<version>1.7.21</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -206,7 +221,7 @@
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>

Expand All @@ -231,6 +246,12 @@
<version>${netty.version}</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down Expand Up @@ -321,7 +342,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -334,7 +355,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -350,7 +371,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.2</version>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -362,7 +383,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5</version>
<version>${maven-release-plugin.version}</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
Expand Down Expand Up @@ -465,7 +486,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.2</version>
<version>3.0.3</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
Expand All @@ -484,7 +505,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<version>0.7.7.201606060606</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
import javax.ws.rs.client.WebTarget;

import com.github.dockerjava.api.command.UpdateContainerCmd;

import com.github.dockerjava.core.SSLConfig;

import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.glassfish.jersey.CommonProperties;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.slf4j.Logger;
Expand Down Expand Up @@ -85,7 +86,6 @@
import com.github.dockerjava.api.command.RenameContainerCmd;
import com.github.dockerjava.api.exception.DockerClientException;
import com.github.dockerjava.core.DockerClientConfig;
import com.github.dockerjava.jaxrs.connector.ApacheConnectorProvider;
import com.github.dockerjava.jaxrs.filter.JsonClientFilter;
import com.github.dockerjava.jaxrs.filter.ResponseStatusExceptionFilter;
import com.github.dockerjava.jaxrs.filter.SelectiveLoggingFilter;
Expand Down Expand Up @@ -115,6 +115,8 @@ public class DockerCmdExecFactoryImpl implements DockerCmdExecFactory {

private DockerClientConfig dockerClientConfig;

private PoolingHttpClientConnectionManager connManager = null;

@Override
public void init(DockerClientConfig dockerClientConfig) {
checkNotNull(dockerClientConfig, "config was not specified");
Expand Down Expand Up @@ -187,8 +189,21 @@ public void init(DockerClientConfig dockerClientConfig) {
configureProxy(clientConfig, protocol);
}

PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(getSchemeRegistry(
originalUri, sslContext));
connManager = new PoolingHttpClientConnectionManager(getSchemeRegistry(
originalUri, sslContext)) {

@Override
public void close() {
super.shutdown();
}

@Override
public void shutdown() {
// Disable shutdown of the pool. This will be done later, when this factory is closed
// This is a workaround for finalize method on jerseys ClientRuntime which
// closes the client and shuts down the connection pool when it is garbage collected
}
};

if (maxTotalConnections != null) {
connManager.setMaxTotal(maxTotalConnections);
Expand Down Expand Up @@ -412,7 +427,6 @@ public KillContainerCmd.Exec createKillContainerCmdExec() {
return new KillContainerCmdExec(getBaseResource(), getDockerClientConfig());
}


@Override
public UpdateContainerCmd.Exec createUpdateContainerCmdExec() {
return new UpdateContainerCmdExec(getBaseResource(), getDockerClientConfig());
Expand Down Expand Up @@ -527,6 +541,7 @@ public DisconnectFromNetworkCmd.Exec createDisconnectFromNetworkCmdExec() {
public void close() throws IOException {
checkNotNull(client, "Factory not initialized. You probably forgot to call init()!");
client.close();
connManager.close();
}

public DockerCmdExecFactoryImpl withReadTimeout(Integer readTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import java.net.URI;

import org.apache.http.HttpHost;
import org.apache.http.annotation.Immutable;
import org.apache.http.annotation.Contract;
import org.apache.http.annotation.ThreadingBehavior;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.protocol.HttpContext;
Expand All @@ -38,7 +39,7 @@
/**
* Provides a ConnectionSocketFactory for connecting Apache HTTP clients to Unix sockets.
*/
@Immutable
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
public class UnixConnectionSocketFactory implements ConnectionSocketFactory {

private File socketFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public Void call() throws Exception {
return null;
}

try {
InputStream inputStream = new WrappedResponseInputStream(response);
try (InputStream inputStream = new WrappedResponseInputStream(response)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcuslinke resource leak fix


if (resultCallback != null) {
responseStreamProcessor.processResponseStream(inputStream, resultCallback);
Expand Down
Loading