Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 89443 invoked from network); 18 Aug 2006 02:23:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2006 02:23:15 -0000 Received: (qmail 92125 invoked by uid 500); 18 Aug 2006 02:23:14 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 92100 invoked by uid 500); 18 Aug 2006 02:23:14 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 92089 invoked by uid 99); 18 Aug 2006 02:23:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 19:23:14 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Aug 2006 19:23:13 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A98A57142A7 for ; Fri, 18 Aug 2006 02:20:15 +0000 (GMT) Message-ID: <20207643.1155867615691.JavaMail.jira@brutus> Date: Thu, 17 Aug 2006 19:20:15 -0700 (PDT) From: "Paulex Yang (JIRA)" To: harmony-commits@incubator.apache.org Subject: [jira] Closed: (HARMONY-1189) [classlib][luni] java.net.HttpURLConnection.getHeaderFieldXXX family methods return incorrect value when http server replied bad response code. In-Reply-To: <26819760.1155627314106.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/HARMONY-1189?page=all ] Paulex Yang closed HARMONY-1189. -------------------------------- Verified by Andrew. > [classlib][luni] java.net.HttpURLConnection.getHeaderFieldXXX family methods return incorrect value when http server replied bad response code. > ----------------------------------------------------------------------------------------------------------------------------------------------- > > Key: HARMONY-1189 > URL: http://issues.apache.org/jira/browse/HARMONY-1189 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Andrew Zhang > Assigned To: Paulex Yang > Attachments: Harmony-1189.diff > > > java.net.HttpURLConnection.getHeaderField family method returns incorrect value when http server replies bad response code. > Following test reproduces the bug (Not stable though): > public void test_getHeaderField() throws Exception { > MockServer server = new MockServer(); > URL u = new URL("http://127.0.0.1:" + server.getLocalPort()); > server.start(); > Thread.sleep(1000); > HttpURLConnection conn = (HttpURLConnection) u.openConnection(); > assertEquals("text/html", conn.getHeaderField("content-type")); > assertEquals("1234", conn.getHeaderField("content-length")); > assertEquals("text/html", conn.getHeaderField(2)); > assertEquals("1234", conn.getHeaderField(3)); > assertEquals("Content-Type", conn.getHeaderFieldKey(2)); > assertEquals("Content-Length", conn.getHeaderFieldKey(3)); > Map> fields = conn.getHeaderFields(); > assertNotNull(fields); > } > private class MockServer extends Thread { > ServerSocket ss; > Socket client; > MockServer() throws Exception { > ss = new ServerSocket(0); > } > public void run() { > try { > client = ss.accept(); > OutputStream os = client.getOutputStream(); > String content = "HTTP/1.1 404 Page Not Found\r\npath=/; domain=apache.com\r\nContent-Type: text/html\r\nContent-Length: 1234\r\n\r\n"; > os.write(content.getBytes("ISO-8859-1")); > // os.close(); > } catch (IOException e) { > } finally { > try { > client.close(); > } catch (Exception e) { > // ignore > } > try { > ss.close(); > } catch (Exception e) { > // ignore > } > } > } > int getLocalPort() { > return ss.getLocalPort(); > } > } > The test passes against RI while fails against Harmony. > I'll upload a patch to solve this problem soon, but without test, because the test depends on multi-thread race. > Thanks! > Best regards, > Andrew -- 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