我是靠谱客的博主 强健大象,最近开发中收集的这篇文章主要介绍[已解决] java.net.InetAddress.getHostName() 阻塞问题,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

在学习java nio的过程中发现某些情况下使用该方法会导致程序阻塞,(情况:服务器,Linux;客户端,WIN10)

java.net.InetAddress.getHostName()

阻塞情况如下:

"TCP:Selector@server:/192.168.0.117:18300" prio=6 tid=0x0000000007eff800 nid=0x3674 runnable [0x00000000093ae000]
   java.lang.Thread.State: RUNNABLE
    at java.net.Inet6AddressImpl.getHostByAddr(Native Method)
    at java.net.InetAddress$1.getHostByAddr(InetAddress.java:880)
    at java.net.InetAddress.getHostFromNameService(InetAddress.java:559)
    at java.net.InetAddress.getHostName(InetAddress.java:502)
    at java.net.InetAddress.getHostName(InetAddress.java:474)
    at com.gifisan.nio.component.AbstractEndPoint.getRemoteHost(AbstractEndPoint.java:69)
    at com.gifisan.nio.component.AbstractEndPoint.toString(AbstractEndPoint.java:90)
    at com.gifisan.nio.common.MessageFormatter.safeObjectAppend(MessageFormatter.java:138)
    at com.gifisan.nio.common.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:110)
    at com.gifisan.nio.common.MessageFormatter.arrayFormat(MessageFormatter.java:68)
    at com.gifisan.nio.common.MessageFormatter.format(MessageFormatter.java:16)
    at com.gifisan.nio.component.IOSession.toString(IOSession.java:245)
    at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:304)
    at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:276)
    at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:230)
    at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:124)
    at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:228)
    at com.gifisan.nio.common.SLF4JLogger.debug(SLF4JLogger.java:45)
    at com.gifisan.nio.component.LoggerSEtListener.sessionOpened(LoggerSEtListener.java:11)
    at com.gifisan.nio.component.SessionEventListenerWrapper.sessionOpened(SessionEventListenerWrapper.java:22)
    at com.gifisan.nio.component.DefaultTCPEndPoint.<init>(DefaultTCPEndPoint.java:55)
    at com.gifisan.nio.connector.TCPSelectionConnector.attachEndPoint(TCPSelectionConnector.java:50)
    at com.gifisan.nio.connector.TCPSelectionConnector.finishConnect(TCPSelectionConnector.java:66)
    at com.gifisan.nio.connector.TCPSelectionConnector.accept(TCPSelectionConnector.java:40)
    at com.gifisan.nio.component.TCPSelectorLoop.accept(TCPSelectorLoop.java:40)
    at com.gifisan.nio.component.AbstractSelectorLoop.loop(AbstractSelectorLoop.java:45)
    at com.gifisan.nio.component.concurrent.UniqueThread.loop(UniqueThread.java:44)
    at com.gifisan.nio.component.concurrent.UniqueThread$1.run(UniqueThread.java:30)
    at java.lang.Thread.run(Thread.java:662)

   Locked ownable synchronizers:
    - None

网上找了下有人说是jdk的bug,不过这为直接crashes了,

http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6487744

ITEYE:

http://jiajianchao-gmail-com.iteye.com/blog/1597253

 

 文章来源:http://www.cnblogs.com/gifisan/p/5695013.html  

转载于:https://www.cnblogs.com/gifisan/p/5695013.html

最后

以上就是强健大象为你收集整理的[已解决] java.net.InetAddress.getHostName() 阻塞问题的全部内容,希望文章能够帮你解决[已解决] java.net.InetAddress.getHostName() 阻塞问题所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部