harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-6504) [classlib][luni]Harmony returns null for header related function when file URL is handled
Date Thu, 22 Apr 2010 00:41:51 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-6504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12859608#action_12859608
] 

Kevin Zhou commented on HARMONY-6504:
-------------------------------------

For instance, given a test case [1], RI passes while HARMONY throws a StringIndexOutOfBoundsException
as follows:

java.lang.StringIndexOutOfBoundsException
	at java.lang.String.<init>(String.java)
	at java.net.URLConnection.guessContentTypeFromStream(URLConnection.java:723)

[1] Test Case
    public void test_EmptyInputStream() throws IOException {
        // try to guess from an empty string
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
        assertNull(URLConnection.guessContentTypeFromStream(bais));
    }

> [classlib][luni]Harmony returns null for header related function when file URL is handled
> -----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6504
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6504
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M14
>         Environment: All platforms
>            Reporter: Mohanraj Loganathan
>            Assignee: Kevin Zhou
>         Attachments: HARMONY-6504.diff
>
>
> Header related functions [getHeaderField(int)/getHeaderFieldKey(int)/getHeaderField(String)/getLastModified()]
returns null when file URL is handled.
> Consider the following test function, which fails with Harmony
>       public void test() throws Exception{
>         String resourceName = "org/apache/harmony/luni/tests/";  //folder name
>         URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
>         FileURLConnection conn = new FileURLConnection(url);
>         assertNotNull(conn.getInputStream());
>         assertEquals(conn.getContentType(),  conn.getHeaderField("content-type")) ;
>         
>         resourceName = "org/apache/harmony/luni/tests/"   "test.rtf";;  //folder name
>         url = ClassLoader.getSystemClassLoader().getResource(resourceName);
>         conn = new FileURLConnection(url);
>         assertNotNull(conn.getInputStream());
>         assertEquals(conn.getContentType(),  conn.getHeaderField("content-type")) ;
>         assertEquals(Integer.toString(conn.getContentLength()),  conn.getHeaderField("content-length"))
;
>         assertEquals(conn.getHeaderField(0), conn.getHeaderField("content-type"));
>         assertEquals(conn.getHeaderField(1), conn.getHeaderField("content-length"));
>         assertEquals(conn.getHeaderField(2), conn.getHeaderField("last-modified"));
>         assertEquals("last-modified", conn.getHeaderFieldKey(2));
>         assertEquals("content-length", conn.getHeaderFieldKey(1));
>         assertEquals("content-type", conn.getHeaderFieldKey(0));
>       }
> Thanks and Regards,
> Mohan

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


Mime
View raw message