• [已解决] 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  

  • 相关阅读:
    阿里云服务器mysql连接不了2003 -can't connect to mysql server on 'ip' (10038)
    androidstudio代码混淆
    apk反编译
    android bottomnavicationbar底部图标vector设计
    Java++:不要随意使用 Cookie 会引火烧身的
    Java++:用户认证-基于 jwt 和 session 的区别和优缺点
    Spring++:AOP 拦截 Service | Controller 日志
    Spring++:整合 Retry 实现重试机制
    (xxl_job | quartz):XXL_JOB 对比 Quartz 一决高下!
    Spring++:定时任务 Cron表达式详解
  • 原文地址:https://www.cnblogs.com/gifisan/p/5695013.html
Copyright © 2020-2023  润新知