harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Deakin (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2047) [classlib][luni]ClassLoader.getResourceAsStream() fails to get property file with special char in its name
Date Mon, 06 Nov 2006 17:12:38 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-2047?page=comments#action_12447477 ] 
            
Oliver Deakin commented on HARMONY-2047:
----------------------------------------

ok, stepping a little further through the test gives the following stack:

FileURLConnection.<init>(URL) line: 61	
Handler.openConnection(URL) line: 44	
URL.openConnection() line: 659	
URL.openStream() line: 647	
URLAppClassLoader(ClassLoader).getResourceAsStream(String) line: 482	
JIRA2047.main(String[]) line: 8	

The FileURLConnection constructor looks like:

  public FileURLConnection(URL url) {
        super(url);
        if ((fileName = url.getFile()) == null) {
            fileName = "";
        }
        String host = url.getHost();
        if (host != null && host.length() > 0) {
            fileName = "//" + host + fileName;
        }
        fileName = Util.decode(fileName, false);
    }

so we can see that the fileName is constructed from url.getFile(), which will have already
been split around the '#' symbol. As such the FileURLConnection gets created with a fileName
of "c:/path/to/file/AAA" instead of "c:/path/to/file/AAA#.properties". 
I wonder if in the case of file protocol we might want to reappend the reference part of the
URL onto the fileName. 

> [classlib][luni]ClassLoader.getResourceAsStream() fails to get property file with special
char in its name
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2047
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2047
>             Project: Harmony
>          Issue Type: Bug
>            Reporter: Leo Li
>
> ClassLoader.getResourceAsStream() fails to get property file with special char in its
name.
> Here is the testcase:
> (First pls put a property file called "AAA#.properties" in where can be searched by classpath.)
> public void testGetResourceAsStream() throws Exception
> {
>         InputStream in = TestClassLoader.class.getClassLoader().getResourceAsStream("AAA#.properties");
>         assertNotNull(in);
> }

-- 
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

        

Mime
View raw message