-
Bug
-
Resolution: Fixed
-
P3
-
9.0.4, 10, 11
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8206828 | 12 | Xueming Shen | P3 | Resolved | Fixed | team |
JDK-8206605 | 11.0.1 | Xueming Shen | P3 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
Also,
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.16299.309]
A DESCRIPTION OF THE PROBLEM :
In Japanese environment, error messages by Windows
(e.g. "確立された接続がホスト コンピューターのソウトウェアによって中止されました。",
in English: "An established connection was aborted by the software in your host machine.")
are decoded as wrong encoding. This causes mojibake, and users can't understand the error message.
It seems that the original messages are in UTF-8 but they are decoded as CP932(Shift-JIS).
REGRESSION. Last worked in version 8u162
ADDITIONAL REGRESSION INFORMATION:
In jre1.8.0_162, error messages are decoded correctly.
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Cause IOException with nio object.
Then, get error message from the exception with getMessage() or getLocalizedMessage().
Example: attached source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output:
----------------------------
確立された接続がホスト コンピューターのソウトウェアによって中止されました。
確立された接続がホスト コンピューターのソウトウェアによって中止されました。
false
true
----------------------------
or
----------------------------
An established connection was aborted by the software in your host machine.
確立された接続がホスト コンピューターのソウトウェアによって中止されました。
false
true
----------------------------
ACTUAL -
Output:
----------------------------
遒コ遶九&繧後◆謗・邯壹′繝帙せ繝? 繧ウ繝ウ繝斐Η繝シ繧ソ繝シ縺ョ繧ス繧ヲ繝医え繧ァ繧「縺ォ繧医▲縺ヲ荳ュ豁「縺輔l縺セ縺励◆縲?
遒コ遶九&繧後◆謗・邯壹′繝帙せ繝? 繧ウ繝ウ繝斐Η繝シ繧ソ繝シ縺ョ繧ス繧ヲ繝医え繧ァ繧「縺ォ繧医▲縺ヲ荳ュ豁「縺輔l縺セ縺励◆縲?
true
false
----------------------------
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
public class Test {
public static void main(String[] args) throws IOException {
int port = 12345;
ServerSocket server = new ServerSocket(port);
new Thread(() -> {
try
{
server.accept().close(); // socket close imediately
}
catch (IOException e)
{
}
}).start();
try {
SocketChannel channel = SocketChannel.open(new InetSocketAddress("localhost", port));
Thread.sleep(1000);
// write data to the closed connection
for (int i = 0; i < 100; i++)
channel.write(ByteBuffer.wrap("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n".getBytes()));
} catch (InterruptedException|IOException e) {
System.out.println(e.getMessage());
System.out.println(e.getLocalizedMessage());
String msg = e.getLocalizedMessage();
System.out.println(msg.startsWith("遒コ")); // mojibake, should be false
System.out.println(msg.startsWith("確立された接続が")); // japanese message, should be true
}
server.close();
}
}
---------- END SOURCE ----------
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
Also,
java version "10" 2018-03-20
Java(TM) SE Runtime Environment 18.3 (build 10+46)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.16299.309]
A DESCRIPTION OF THE PROBLEM :
In Japanese environment, error messages by Windows
(e.g. "確立された接続がホスト コンピューターのソウトウェアによって中止されました。",
in English: "An established connection was aborted by the software in your host machine.")
are decoded as wrong encoding. This causes mojibake, and users can't understand the error message.
It seems that the original messages are in UTF-8 but they are decoded as CP932(Shift-JIS).
REGRESSION. Last worked in version 8u162
ADDITIONAL REGRESSION INFORMATION:
In jre1.8.0_162, error messages are decoded correctly.
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Cause IOException with nio object.
Then, get error message from the exception with getMessage() or getLocalizedMessage().
Example: attached source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output:
----------------------------
確立された接続がホスト コンピューターのソウトウェアによって中止されました。
確立された接続がホスト コンピューターのソウトウェアによって中止されました。
false
true
----------------------------
or
----------------------------
An established connection was aborted by the software in your host machine.
確立された接続がホスト コンピューターのソウトウェアによって中止されました。
false
true
----------------------------
ACTUAL -
Output:
----------------------------
遒コ遶九&繧後◆謗・邯壹′繝帙せ繝? 繧ウ繝ウ繝斐Η繝シ繧ソ繝シ縺ョ繧ス繧ヲ繝医え繧ァ繧「縺ォ繧医▲縺ヲ荳ュ豁「縺輔l縺セ縺励◆縲?
遒コ遶九&繧後◆謗・邯壹′繝帙せ繝? 繧ウ繝ウ繝斐Η繝シ繧ソ繝シ縺ョ繧ス繧ヲ繝医え繧ァ繧「縺ォ繧医▲縺ヲ荳ュ豁「縺輔l縺セ縺励◆縲?
true
false
----------------------------
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
public class Test {
public static void main(String[] args) throws IOException {
int port = 12345;
ServerSocket server = new ServerSocket(port);
new Thread(() -> {
try
{
server.accept().close(); // socket close imediately
}
catch (IOException e)
{
}
}).start();
try {
SocketChannel channel = SocketChannel.open(new InetSocketAddress("localhost", port));
Thread.sleep(1000);
// write data to the closed connection
for (int i = 0; i < 100; i++)
channel.write(ByteBuffer.wrap("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n".getBytes()));
} catch (InterruptedException|IOException e) {
System.out.println(e.getMessage());
System.out.println(e.getLocalizedMessage());
String msg = e.getLocalizedMessage();
System.out.println(msg.startsWith("遒コ")); // mojibake, should be false
System.out.println(msg.startsWith("確立された接続が")); // japanese message, should be true
}
server.close();
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8206605 System error message is decoded as invalid encoding in Windows.
- Resolved
-
JDK-8206828 System error message is decoded as invalid encoding in Windows.
- Resolved
- relates to
-
JDK-8057777 Cleanup of old and unused VM interfaces
- Closed
-
JDK-8210345 The Japanese message of FileNotFoundException garbled.
- Closed