Skip to content

Commit

Permalink
#291 close streams
Browse files Browse the repository at this point in the history
  • Loading branch information
bsideup committed Feb 21, 2017
1 parent 0e093e4 commit 153e187
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,22 @@ InetSocketAddress start() throws IOException {
Socket incomingSocket = listenSocket.accept();
log.debug("Accepting incoming connection from {}", incomingSocket.getRemoteSocketAddress());

executorService.submit(() -> IOUtils.copyLarge(incomingSocket.getInputStream(), new FileOutputStream(randomAccessFile.getFD())));
executorService.submit(() -> IOUtils.copyLarge(new FileInputStream(randomAccessFile.getFD()), incomingSocket.getOutputStream()));
executorService.submit(() -> {
try (
InputStream in = incomingSocket.getInputStream();
FileOutputStream out = new FileOutputStream(randomAccessFile.getFD())
) {
return IOUtils.copyLarge(in, out);
}
});
executorService.submit(() -> {
try (
FileInputStream in = new FileInputStream(randomAccessFile.getFD());
OutputStream out = incomingSocket.getOutputStream()
) {
return IOUtils.copyLarge(in, out);
}
});

} catch (IOException e) {
log.warn("", e);
Expand Down

0 comments on commit 153e187

Please sign in to comment.