Command resource cleanup after command execution by tedoc2000 · Pull Request #120 · docker-java/docker-java
Expand Up
@@ -40,6 +40,7 @@ public class BuildImageCmdImpl extends AbstrDockerCmd<BuildImageCmd, InputStream
.compile("^ENV\\s+(.*)\\s+(.*)$");
private InputStream tarInputStream = null; private File tarFile = null; private String tag; private boolean noCache; private boolean remove = true; Expand All @@ -48,7 +49,13 @@ public class BuildImageCmdImpl extends AbstrDockerCmd<BuildImageCmd, InputStream public BuildImageCmdImpl(BuildImageCmd.Exec exec, File dockerFolder) { super(exec); Preconditions.checkNotNull(dockerFolder, "dockerFolder is null"); withTarInputStream(buildDockerFolderTar(dockerFolder)); tarFile = buildDockerFolderTar(dockerFolder); try { withTarInputStream(FileUtils.openInputStream(tarFile)); } catch (IOException e) { // we just created the file this should never happen. throw new RuntimeException(e); } }
public BuildImageCmdImpl(BuildImageCmd.Exec exec, InputStream tarInputStream) { Expand Down Expand Up @@ -129,6 +136,14 @@ public BuildImageCmdImpl withQuiet(boolean quiet) { return this; }
@Override public void close() throws IOException { super.close(); if (tarFile != null) { FileUtils.deleteQuietly(tarFile); } }
@Override public String toString() { return new StringBuilder("build ") Expand All @@ -139,7 +154,7 @@ public String toString() { .toString(); }
protected InputStream buildDockerFolderTar(File dockerFolder) { protected File buildDockerFolderTar(File dockerFolder) { Preconditions.checkArgument(dockerFolder.exists(), "Path %s doesn't exist", dockerFolder); Preconditions.checkArgument(dockerFolder.isDirectory(), Expand Down Expand Up @@ -255,9 +270,8 @@ protected InputStream buildDockerFolderTar(File dockerFolder) { } }
dockerFolderTar = CompressArchiveUtil.archiveTARFiles(dockerFolder, return CompressArchiveUtil.archiveTARFiles(dockerFolder, filesToAdd, archiveNameWithOutExtension); return FileUtils.openInputStream(dockerFolderTar); } catch (IOException ex) { FileUtils.deleteQuietly(dockerFolderTar); throw new DockerClientException( Expand Down
private InputStream tarInputStream = null; private File tarFile = null; private String tag; private boolean noCache; private boolean remove = true; Expand All @@ -48,7 +49,13 @@ public class BuildImageCmdImpl extends AbstrDockerCmd<BuildImageCmd, InputStream public BuildImageCmdImpl(BuildImageCmd.Exec exec, File dockerFolder) { super(exec); Preconditions.checkNotNull(dockerFolder, "dockerFolder is null"); withTarInputStream(buildDockerFolderTar(dockerFolder)); tarFile = buildDockerFolderTar(dockerFolder); try { withTarInputStream(FileUtils.openInputStream(tarFile)); } catch (IOException e) { // we just created the file this should never happen. throw new RuntimeException(e); } }
public BuildImageCmdImpl(BuildImageCmd.Exec exec, InputStream tarInputStream) { Expand Down Expand Up @@ -129,6 +136,14 @@ public BuildImageCmdImpl withQuiet(boolean quiet) { return this; }
@Override public void close() throws IOException { super.close(); if (tarFile != null) { FileUtils.deleteQuietly(tarFile); } }
@Override public String toString() { return new StringBuilder("build ") Expand All @@ -139,7 +154,7 @@ public String toString() { .toString(); }
protected InputStream buildDockerFolderTar(File dockerFolder) { protected File buildDockerFolderTar(File dockerFolder) { Preconditions.checkArgument(dockerFolder.exists(), "Path %s doesn't exist", dockerFolder); Preconditions.checkArgument(dockerFolder.isDirectory(), Expand Down Expand Up @@ -255,9 +270,8 @@ protected InputStream buildDockerFolderTar(File dockerFolder) { } }
dockerFolderTar = CompressArchiveUtil.archiveTARFiles(dockerFolder, return CompressArchiveUtil.archiveTARFiles(dockerFolder, filesToAdd, archiveNameWithOutExtension); return FileUtils.openInputStream(dockerFolderTar); } catch (IOException ex) { FileUtils.deleteQuietly(dockerFolderTar); throw new DockerClientException( Expand Down