diff --git a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java index 09cb0a8601a5..04ce26377259 100644 --- a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java +++ b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java @@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.ide.PooledThreadExecutor; import java.io.IOException; +import java.net.BindException; import java.net.InetSocketAddress; import java.net.Socket; @@ -93,7 +94,8 @@ public final class NettyUtil { } return (throwable instanceof IOException && message.equals("An existing connection was forcibly closed by the remote host")) || - (throwable instanceof ChannelException && message.startsWith("Failed to bind to: ")); + (throwable instanceof ChannelException && message.startsWith("Failed to bind to: ")) || + throwable instanceof BindException; } // applicable only in case of ClientBootstrap&OioClientSocketChannelFactory diff --git a/platform/platform-impl/src/org/jetbrains/io/SubServer.java b/platform/platform-impl/src/org/jetbrains/io/SubServer.java index ee070e75f453..9f14762714b6 100644 --- a/platform/platform-impl/src/org/jetbrains/io/SubServer.java +++ b/platform/platform-impl/src/org/jetbrains/io/SubServer.java @@ -47,8 +47,12 @@ final class SubServer implements CustomPortServerManager.CustomPortService, Disp return true; } catch (Exception e) { - NettyUtil.log(e, BuiltInServer.LOG); - user.cannotBind(e, port); + try { + NettyUtil.log(e, BuiltInServer.LOG); + } + finally { + user.cannotBind(e, port); + } return false; } }