4

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!

Patrick
  • 41
  • 2
  • 2
    Could you also update the question with the piece of code to reproduce this? – Naman Dec 18 '17 at 06:05
  • Can you update the question with the stack trace? I can't tell from the question if the issue is the exception message or how it printed to the console. – Alan Bateman Dec 18 '17 at 11:55
  • The issue is the way it is printed to the console. – Patrick Dec 21 '17 at 09:36
  • On java 8, even if Windows is in Japan locale and set to Japanese language, the IOException message is printed correctly in Japanese. – Patrick Dec 22 '17 at 06:12
  • However, it is questionable whether to report the message text of exceptions to users: https://stackoverflow.com/questions/7320080/should-you-report-the-message-text-of-exceptions – Raedwald Dec 22 '17 at 08:48
  • Displayed to the client or not, the problem is that the message from the IOException is garbled. Anyone else has an idea regarding this matter? – Patrick Jan 08 '18 at 07:47
  • Have you try using String.format(Locale.JAPAN, e.toString()); ? There are so many places where the locale can be overridden, it's hard to pinpoint without a minimal, complete, verifiable example. https://stackoverflow.com/help/mcve – Karis Mar 30 '18 at 16:06
  • @Karis are you referring to String​(byte[] bytes, String charsetName) or String​(byte[] bytes, Charset charset)? String.format is a different method for formatting. – Patrick Jul 18 '18 at 08:18
  • @Karis you cannot format a string like that, it's not a format template `%3.2f %s etc` – zapl Jul 18 '18 at 08:33

0 Answers0