Skip to content

Commit

Permalink
#291 create ServerSocket outside of the task
Browse files Browse the repository at this point in the history
  • Loading branch information
bsideup committed Feb 21, 2017
1 parent 153e187 commit 3d871ab
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public NamedPipeProxy(File file) {
}

InetSocketAddress start() throws IOException {
return (InetSocketAddress) executorService.submit(() -> {
ServerSocket listenSocket = new ServerSocket();
listenSocket.bind(new InetSocketAddress("localhost", 0));
ServerSocket listenSocket = new ServerSocket();
listenSocket.bind(new InetSocketAddress("localhost", 0));

executorService.submit(() -> {
log.debug("Listening on {} and proxying to {}", listenSocket.getLocalSocketAddress(), randomAccessFile);

try {
Expand Down Expand Up @@ -87,8 +87,9 @@ InetSocketAddress start() throws IOException {
} finally {
listenSocket.close();
}
return listenSocket.getLocalSocketAddress();
return null;
});
return (InetSocketAddress) listenSocket.getLocalSocketAddress();
}

public void stop() {
Expand Down

0 comments on commit 3d871ab

Please sign in to comment.