Skip to content

Commit

Permalink
Ensure that piped streams are closed automatically. This resolves an …
Browse files Browse the repository at this point in the history
…apparently deadlock somewhere between netty/docker if a previous test, affected by #263, has failed during copying of a file.
  • Loading branch information
rnorth committed Jan 14, 2017
1 parent eb9bd32 commit 52a7250
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 52a7250

Please sign in to comment.