Skip to content

Commit f2191dd

Browse files
author
Kim A. Betti
committed
Added a close method to DockerClient
Give programs using DockerClient an opportunity to release resources claimed by the http client created inside DockerClient.
1 parent cb9b3f2 commit f2191dd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/com/github/dockerjava/client/DockerClient.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import static org.apache.commons.io.IOUtils.closeQuietly;
44

5-
import java.io.File;
6-
import java.io.IOException;
7-
import java.io.InputStream;
8-
import java.io.StringWriter;
5+
import java.io.*;
96
import java.net.URI;
107

118
import org.apache.commons.io.IOUtils;
@@ -60,7 +57,7 @@
6057
/**
6158
* @author Konstantin Pelykh (kpelykh@gmail.com)
6259
*/
63-
public class DockerClient {
60+
public class DockerClient implements Closeable {
6461

6562
private Client client;
6663
private WebResource baseResource;
@@ -321,4 +318,10 @@ public static String asString(ClientResponse response) throws IOException {
321318
}
322319
return out.toString();
323320
}
321+
322+
@Override
323+
public void close() throws IOException {
324+
client.destroy();
325+
}
326+
324327
}

0 commit comments

Comments
 (0)