Skip to content

Commit

Permalink
Merge pull request #274 from testcontainers/fix-dockerfile-resource-leak
Browse files Browse the repository at this point in the history
Ensure that piped streams are closed automatically
  • Loading branch information
bsideup committed Jan 21, 2017
2 parents 638e4d0 + dc1b260 commit 339d7ce
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.dockerjava.api.model.BuildResponseItem;
import com.github.dockerjava.core.command.BuildImageResultCallback;
import com.google.common.collect.Sets;
import lombok.Cleanup;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
Expand Down Expand Up @@ -113,8 +114,8 @@ public void onNext(BuildResponseItem item) {
};

// We have to use pipes to avoid high memory consumption since users might want to build really big images
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
@Cleanup PipedInputStream in = new PipedInputStream();
@Cleanup PipedOutputStream out = new PipedOutputStream(in);

profiler.start("Configure image");
BuildImageCmd buildImageCmd = dockerClient.buildImageCmd(in);
Expand Down

0 comments on commit 339d7ce

Please sign in to comment.