JDK-4818488 : (so) Missing encoding conversion in handleSocketError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.1,1.4.2_08,5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris,solaris_10,windows_xp
  • CPU: generic,x86,sparc
  • Submitted: 2003-02-13
  • Updated: 2006-06-21
  • Resolved: 2006-06-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
1.4.2_14Fixed 6 b89Fixed
It appears that an encoding conversion is missing when the function handleSocketError in src/solaris/native/sun/nio/ch/Net.c obtains a string from the C library function strerror and then passes it on to the JNI utility JNU_ThrowByNameWithLastError. C library functions use the native encoding of the current locale, e.g., EUC-JP for Japanese, while JNI functions generally expect Java-modified UTF-8.

EVALUATION The fix is to set the "errorValue" back into "errno" then let JNU_ThrowByNameWithLastError do the job. A regression test is NOT included in the bugfix putback, because it's hard to write a good one, which probably needs to figure out how to handle/play with (1)a local version of OS (2)appropriately installed l10n message pacakges (3)set the correct testing locale (4)run the java test case (5)the test case also need to figure out how to verify an output text msessage is "correct" (not garbled), meant you need to find an appropriate "golden data" based on the locale/os/version to match the output...probably not worth the energy. A simple test case below can help you manually verify the bug and its fix, for example on a Japanese Solaris do something like (1)setenv LC_ALL ja (2)java ExceptionMsg 2>& output (3)verify the text in "output" via a browser, with encoding set to euc-jp. public class ExceptionMsg { public static void main(String[] args) throws Throwable{ try { SocketChannel socketChannel = SocketChannel.open(); boolean b = socketChannel.connect(new InetSocketAddress("javaweb.sfbay", 4444)); } catch (IOException e) { System.out.println(e.getMessage()); } } }

EVALUATION This should be fixed in Tiger. ###@###.### 2003-02-14