harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikolay Kuznetsov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2478) [classlib][net]ContentHandler.getContent(Class[]) determines returned object incorrectly
Date Tue, 05 Dec 2006 20:08:21 GMT
[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:
java test
content= sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1b65ab

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


View raw message