JDK-6274990 : REGRESSION: URLConnection.connect() throws Exception with non UTF-8 char
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,linux
  • CPU: generic,x86,itanium
  • Submitted: 2005-05-24
  • Updated: 2010-04-02
  • Resolved: 2005-08-05
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
5.0u7Fixed 6 betaFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux ulysses 2.2.19pre17 #1 Tue Mar 13 22:37:59 EST 2001 i586 unknown
Microsoft Windows XP [Version 5.1.2600]


A DESCRIPTION OF THE PROBLEM :
The directory name part of URL is the one that  "Day" of the Chinese character was shown by the ShiftJIS character-code.

class Bug {
    public static void main(String[] args) throws Exception {
        java.net.URL url = new java.net.URL("http://www.example.com/%93%fa/");
        java.net.URLConnection uc = url.openConnection();
        uc.connect();
    }
}

results in:
Exception in thread "main" java.lang.IllegalArgumentException
        at sun.net.www.ParseUtil.decode(ParseUtil.java:179)
        at sun.net.www.ParseUtil.toURI(ParseUtil.java:253)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:738)
        at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:669)
        at Bug.main(Bug.java:5)


REPRODUCIBILITY :
This bug can be reproduced always.

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-05-24 03:39:16 GMT

Comments
EVALUATION To fix 6181108, an extra decode step is introduced (ParseUtil.java line 253) path = decode(path); But ParseUtil.decode(...) expectes UTF-8 encoded string. The intention of the fix of 6181108 is actually un-escape string, not decode UTF-8 string. So the fix causes the regression. ###@###.### 2005-06-07 10:20:45 GMT The fix includes 2 parts actually: 1. revoke the fix for 6181108, so eliminate the regression, i.e. fix this bug. 2. fix 6181108 again by fixing URI.quote(...), that's the root cause of the defect. ###@###.### 2005-06-08 09:48:09 GMT It truns out the current behavior of java.net.URI must be preserved. So the fix will be: 1. revoke the fix for 6181108, so eliminate the regression, i.e. fix this bug. 2. fix 6181108 again by using java.net.URI's single-argument constructor, which doesn't double-encode the string. ###@###.### 2005-07-20 08:08:49 GMT
07-06-2005