Remove usage of getLocalHost, other minor changes related to localhost connections in daemon

- attempt to fix behaviours similar to #IDEA-161962, #KT-14042
This commit is contained in:
Ilya Chernikov
2016-10-02 18:35:31 +02:00
parent ea4a1df839
commit 16897f4935
2 changed files with 4 additions and 4 deletions
@@ -67,7 +67,7 @@ fun walkDaemons(registryDir: File,
private inline fun tryConnectToDaemon(port: Int, report: (DaemonReportCategory, String) -> Unit): CompileService? { private inline fun tryConnectToDaemon(port: Int, report: (DaemonReportCategory, String) -> Unit): CompileService? {
try { try {
val daemon = LocateRegistry.getRegistry(LoopbackNetworkInterface.loopbackInetAddressName, port) val daemon = LocateRegistry.getRegistry(LoopbackNetworkInterface.loopbackInetAddressName, port, LoopbackNetworkInterface.clientLoopbackSocketFactory)
?.lookup(COMPILER_SERVICE_RMI_NAME) ?.lookup(COMPILER_SERVICE_RMI_NAME)
when (daemon) { when (daemon) {
null -> report(DaemonReportCategory.EXCEPTION, "daemon not found") null -> report(DaemonReportCategory.EXCEPTION, "daemon not found")
@@ -46,7 +46,7 @@ object LoopbackNetworkInterface {
// TODO switch to InetAddress.getLoopbackAddress on java 7+ // TODO switch to InetAddress.getLoopbackAddress on java 7+
val loopbackInetAddressName by lazy { val loopbackInetAddressName by lazy {
try { try {
if (InetAddress.getLocalHost() is Inet6Address) IPV6_LOOPBACK_INET_ADDRESS else IPV4_LOOPBACK_INET_ADDRESS if (InetAddress.getByName(null) is Inet6Address) IPV6_LOOPBACK_INET_ADDRESS else IPV4_LOOPBACK_INET_ADDRESS
} }
catch (e: IOException) { catch (e: IOException) {
// getLocalHost may fail for unknown reasons in some situations, the fallback is to assume IPv4 for now // getLocalHost may fail for unknown reasons in some situations, the fallback is to assume IPv4 for now
@@ -63,7 +63,7 @@ object LoopbackNetworkInterface {
override fun hashCode(): Int = super.hashCode() override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class) @Throws(IOException::class)
override fun createServerSocket(port: Int): ServerSocket = ServerSocket(port, SERVER_SOCKET_BACKLOG_SIZE, InetAddress.getByName(loopbackInetAddressName)) override fun createServerSocket(port: Int): ServerSocket = ServerSocket(port, SERVER_SOCKET_BACKLOG_SIZE, InetAddress.getByName(null))
} }
@@ -72,7 +72,7 @@ object LoopbackNetworkInterface {
override fun hashCode(): Int = super.hashCode() override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class) @Throws(IOException::class)
override fun createSocket(host: String, port: Int): Socket = Socket(InetAddress.getByName(loopbackInetAddressName), port) override fun createSocket(host: String, port: Int): Socket = Socket(InetAddress.getByName(null), port)
} }
} }