You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Ray Chen (JIRA)" <ji...@apache.org> on 2010/03/10 07:23:27 UTC
[jira] Created: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
[classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
---------------------------------------------------------------------------------------------------
Key: HARMONY-6464
URL: https://issues.apache.org/jira/browse/HARMONY-6464
Project: Harmony
Issue Type: Bug
Components: Classlib
Reporter: Ray Chen
Priority: Minor
Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843900#action_12843900 ]
Nathan Beyer commented on HARMONY-6464:
---------------------------------------
+ private static String defaultEncoding;
@Deprecated
public static String encode(String s) {
+ if (defaultEncoding == null) {
+ defaultEncoding = System.getProperty("file.encoding");
+ }
This isn't thread-safe and I'm not sure that it's warranted to cache the default encoding.
> [classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
> ---------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6464
> URL: https://issues.apache.org/jira/browse/HARMONY-6464
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Ray Chen
> Priority: Minor
> Attachments: Harmony-6464.diff
>
>
> Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
> In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6464?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6464:
------------------------------
Attachment: Harmony-6464-V2.diff
Hi Nathan,
How about the new version patch?
> [classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
> ---------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6464
> URL: https://issues.apache.org/jira/browse/HARMONY-6464
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Ray Chen
> Priority: Minor
> Attachments: Harmony-6464-V2.diff, Harmony-6464.diff
>
>
> Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
> In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6464?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6464:
------------------------------
Attachment: Harmony-6464.diff
The patch fixed the bug, and add a regression test
> [classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
> ---------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6464
> URL: https://issues.apache.org/jira/browse/HARMONY-6464
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Ray Chen
> Priority: Minor
> Attachments: Harmony-6464.diff
>
>
> Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
> In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843899#action_12843899 ]
Nathan Beyer commented on HARMONY-6464:
---------------------------------------
The behavior isn't incorrect - it's using the default encoding - that's what happens when String.getBytes() is called with no encoding passed.
> [classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
> ---------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6464
> URL: https://issues.apache.org/jira/browse/HARMONY-6464
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Ray Chen
> Priority: Minor
> Attachments: Harmony-6464.diff
>
>
> Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
> In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843901#action_12843901 ]
Nathan Beyer commented on HARMONY-6464:
---------------------------------------
I don't quite understand why the original method is left at all.
+ try {
+ return encode(s, defaultEncoding);
+ } catch (UnsupportedEncodingException e) {
+ return doDefaultEncode(s);
+ }
+ }
+
+ private static String doDefaultEncode(String s) {
The catch can't happen - if the platform's default encoding (file.encoding) was unsupported, I'd be surprised if the runtime lasted long enough to invoke this. This seems like a case where a 'throws AssertionError(e)' idiom would be used to define a system assert.
> [classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
> ---------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6464
> URL: https://issues.apache.org/jira/browse/HARMONY-6464
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Ray Chen
> Priority: Minor
> Attachments: Harmony-6464.diff
>
>
> Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
> In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6464)
[classlib][luni]URLEncoder.encode(String) should same as
URLEncoder.encode(String, defaultEncoding)
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12843905#action_12843905 ]
Ray Chen commented on HARMONY-6464:
-----------------------------------
Hi Nathan,
Thank you for your comments. My reply as below
<Ray>
I checked the URLDecoder, it also has a catch for
UnsupportedCharsetException, that's why I kept the doDefautEncode(),
if it is not neccessary, I will delete it.
</Ray>
> @Deprecated
> public static String encode(String s) {
<Ray>
Again I refered to URLDecoder, acutally I didn't cache the
defautlEncoding at first, I guess there may be a performance concern
here. So if there is
thread-safe problem here, URLDecoder may also have this problem.
So shall I delete this cache, and call getProperty() every time? Or
there are any better solution?
</Ray>
--
Regards,
Ray Chen
> [classlib][luni]URLEncoder.encode(String) should same as URLEncoder.encode(String, defaultEncoding)
> ---------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6464
> URL: https://issues.apache.org/jira/browse/HARMONY-6464
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: Ray Chen
> Priority: Minor
> Attachments: Harmony-6464.diff
>
>
> Although URLEncoder.encode(String) is deprecated, but its behavior should be as same as URLEncoder.encode(String, defaultEncoding)
> In which defaultEncoding = System.getProperty("file.encoding");
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.