You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Leo Li (JIRA)" <ji...@apache.org> on 2006/11/22 05:24:02 UTC

[jira] Created: (HARMONY-2255) [luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

[luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
---------------------------------------------------------------------------

                 Key: HARMONY-2255
                 URL: http://issues.apache.org/jira/browse/HARMONY-2255
             Project: Harmony
          Issue Type: Bug
            Reporter: Leo Li


Here is the testcase:

public void testGetResourceAsStream() throws Exception 
    { 
            InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
            assertNotNull(in); 
    } 

RI passes
Harmony fails

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499790 ] 

Alexei Zakharov commented on HARMONY-2255:
------------------------------------------

Mikhail, looks like after committing HARMONY-3983 today your patch become outdated. And I can't find an easy way to apply it in its current form. Could please rework it and make it compatible with the current repository state. Thanks!

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>            Assignee: Alexei Zakharov
>         Attachments: H-2255.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-2255:
------------------------------------

    Attachment: H-2255.patch

Here is the patch fixing the issue + regression test.

Fix description: added 'escaping' of '%' symbol in the resource name before decoding to avoid IAE.

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>         Attachments: H-2255.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12497836 ] 

Mikhail Markov commented on HARMONY-2255:
-----------------------------------------

Well, i've figured out why the decoding is used: for handling special characters like "#" - if just remove the mentioned code, the regression test URLClassLoaderTest.testFindResource_H3461() starts failing, so this simple "fix" is not appropriate.
I'll try to find a better one :-).

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov closed HARMONY-2255.
------------------------------------


Excellent. Looks like we have nothing more to do with this JIRA. Closed.

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>            Assignee: Alexei Zakharov
>         Attachments: H-2255.patch, H-2255_upd.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-2255:
------------------------------------

    Attachment: H-2255_upd.patch

Alexei, here is the updated patch - try it, please. Thanks!

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>            Assignee: Alexei Zakharov
>         Attachments: H-2255.patch, H-2255_upd.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496947 ] 

Mikhail Markov commented on HARMONY-2255:
-----------------------------------------

I've found that the problem is in URLClassLoader. See the following piece of code from findResourceImpl method:

try {
    filename = URLDecoder.decode(filename, "UTF-8"); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
    return null;
}
The documentation for URLDecoder states that '%' is treated as special character, so URLDecoder.decode() method should not be used in findResourceImpl method. If I just commet this piece of code, the test above starts working. The other tests also work without problems.
The variable filename is just used later in this expression "new File(filename).exists())" and I do not see any reason of converting the filename to UTF8 as File should work with unicode just fine.

So, I suggest to just remove the mentioned piece of code from URLClassLoader.findResourceImpl method.
Does anybody know what was the original purpose of having it there?

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500071 ] 

Mikhail Markov commented on HARMONY-2255:
-----------------------------------------

Thanks, Alexei - i like your approach! The fix works for me as expected.

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>            Assignee: Alexei Zakharov
>         Attachments: H-2255.patch, H-2255_upd.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-2255.
--------------------------------------

    Resolution: Fixed

Hi Mikhail, thanks. I am able to apply this one. However, I've made some changes to your patch before committing. IMO it is a bit silly to encode something manually if it will be decoded in the next line. An easy fix for this is not to encode/decode at all as it was suggested in your first comment. :) In URLFileHandler.findResource() only prefix can be encoded, not name. Please look at my fix at r542658 and verify if it is ok. Thanks.

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>            Assignee: Alexei Zakharov
>         Attachments: H-2255.patch, H-2255_upd.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Alexey Petrenko (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Petrenko updated HARMONY-2255:
-------------------------------------

    Summary: [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"  (was: [luni]ClassLoader.getResourceAsStream fails to get file whose name with "%")

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-2255) [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-2255:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][luni]ClassLoader.getResourceAsStream fails to get file whose name with "%"
> -------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2255
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2255
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Leo Li
>            Assignee: Alexei Zakharov
>         Attachments: H-2255.patch
>
>
> Here is the testcase:
> public void testGetResourceAsStream() throws Exception 
>     { 
>             InputStream in = this.getClass().getClassLoader().getResourceAsStream("AAA%.properties"); 
>             assertNotNull(in); 
>     } 
> RI passes
> Harmony fails

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.