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

[jira] Updated: (HARMONY-2478) [classlib][net]ContentHandler.getContent(Class[]) determines returned object incorrectly

     [ http://issues.apache.org/jira/browse/HARMONY-2478?page=all ]

Nikolay Kuznetsov updated HARMONY-2478:
---------------------------------------

    Attachment: test.java

> [classlib][net]ContentHandler.getContent(Class[]) determines returned object incorrectly
> ----------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2478
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2478
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Nikolay Kuznetsov
>         Attachments: test.java
>
>
> The attached test(which queries new URL("http://www.intel.com").getContent({ Object.class })) fails to return content type properly as RI does:
> RI:
> java test
> content= sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1b65ab
> Harmony:
> ./java test
> content= null
> Content is null
> While getContent(_void_) method returns org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection$LimitedInputStream@2061b4bc
> The problem here is that in HARMONY implmentation of ContentHandler.getContent(Class[]) uses reference equality to determine returned object instead of instanceof operator, while specification reads that:
> "The instanceof operator should be used to determine the specific kind of object returned".
> see code sample from ContentHandlers below.
> public Object getContent(URLConnection uConn, Class[] types)
>             throws IOException {
>         Object content = getContent(uConn);
>         Class<?> cl = content.getClass();
>         for (int i = 0; i < types.length; i++) {
>             if (cl == types[i]) { //ERROR HERE isInstance should be used !!!
>                 return content;
>             }
>         }
>         return null;
>     }

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