IOException message not printed correctly when using Java 9 on Windows 10 set to Japan locale and language

。_饼干妹妹 提交于 2019-12-10 16:28:25

问题


An Exception is thrown in this particular block.

   try
   {
       transport.m_readListener.onReadTransport(transport);
   }
   catch (IOException e)
   {
       ->onIOException(e,transport);
   }

The onIOException() method puts it on the log:

    private void onIOException(IOException e, AbstractConnection connection)
    {
        String reason = e.getMessage();
        ...
        log.error("Closing ",connection," because ",reason);
    }

The reason variable in Java 8 shows a correct japanese phrase:

reason : 既存の接続はリモート ホストに強制的に切断されました。 (meaning: The existing connection was forcibly disconnected to the remote host)

When ran on Java 9, the exception message is now broken:

reason : 譌「蟄倥?ョ謗・邯壹?ッ繝ェ繝「繝シ繝? 繝帙せ繝医↓蠑キ蛻カ逧?縺ォ蛻?譁ュ縺輔l縺セ縺励◆縲?

The code block that checks if the Socket port is still open is inside a try catch block that catches the IOException. The message from the IOException is acquired via

    String reason = e.getMessage();
    if (null == reason) reason = e.toString();

Tried running the app with java.locale.providers=COMPAT,CLDR,SPI to make it behave like in Java 8 but nothing happens. Anyone has an idea on this issue? Can anyone help? Thanks!

来源:https://stackoverflow.com/questions/47862637/ioexception-message-not-printed-correctly-when-using-java-9-on-windows-10-set-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!