Skip to content

Commit

Permalink
Fix #5794 Close socket on bind failure
Browse files Browse the repository at this point in the history
Update fix with IO.close()
  • Loading branch information
gregw committed Dec 14, 2020
1 parent f2e8706 commit 420093e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Expand Up @@ -336,12 +336,11 @@ protected ServerSocketChannel openAcceptChannel() throws IOException

if (serverChannel == null)
{
serverChannel = ServerSocketChannel.open();

InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
serverChannel.socket().setReuseAddress(getReuseAddress());
serverChannel = ServerSocketChannel.open();
try
{
serverChannel.socket().setReuseAddress(getReuseAddress());
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
}
catch (Throwable e)
Expand Down
Expand Up @@ -271,9 +271,9 @@ private ServerSocket listen()
try
{
ServerSocket serverSocket = new ServerSocket();
serverSocket.setReuseAddress(true);
try
{
serverSocket.setReuseAddress(true);
serverSocket.bind(new InetSocketAddress(InetAddress.getByName(host), port));
}
catch (Throwable e)
Expand Down

0 comments on commit 420093e

Please sign in to comment.