Skip to content

Commit

Permalink
testcontainers#291 use ByteStreams
Browse files Browse the repository at this point in the history
  • Loading branch information
bsideup committed Feb 21, 2017
1 parent fa7e9d9 commit ed0f64d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientConfig;
import com.google.common.io.ByteStreams;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;

import java.io.*;
Expand Down Expand Up @@ -89,27 +89,27 @@ InetSocketAddress start() throws IOException {
executorService.submit(() -> {
try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {
log.info("Created RandomAccessFile from " + file);
Future<Integer> inputFuture = executorService.submit(() -> {
Future<Long> inputFuture = executorService.submit(() -> {
try (
InputStream in = incomingSocket.getInputStream();
FileOutputStream out = new FileOutputStream(randomAccessFile.getFD())
) {
return IOUtils.copy(in, out);
return ByteStreams.copy(in, out);
} catch (Exception e) {
log.warn("", e);
return -1;
return null;
}
});

Future<Integer> outputFuture = executorService.submit(() -> {
Future<Long> outputFuture = executorService.submit(() -> {
try (
FileInputStream in = new FileInputStream(randomAccessFile.getFD());
OutputStream out = incomingSocket.getOutputStream()
) {
return IOUtils.copy(in, out);
return ByteStreams.copy(in, out);
} catch (Exception e) {
log.warn("", e);
return -1;
return null;
}
});

Expand Down

0 comments on commit ed0f64d

Please sign in to comment.