Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 69727 invoked from network); 24 Jul 2010 12:37:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jul 2010 12:37:25 -0000 Received: (qmail 55884 invoked by uid 500); 24 Jul 2010 12:37:25 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 55784 invoked by uid 500); 24 Jul 2010 12:37:22 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 55776 invoked by uid 99); 24 Jul 2010 12:37:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jul 2010 12:37:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Jul 2010 12:37:21 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6OCb0ml027774 for ; Sat, 24 Jul 2010 12:37:00 GMT Message-ID: <10459949.567371279975020424.JavaMail.jira@thor> Date: Sat, 24 Jul 2010 08:37:00 -0400 (EDT) From: "deven you (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6590) [classlib][luni]A issue about CharsetEncoder.flush() in the OutputStreamWriter.close() In-Reply-To: <502799.410621279261189857.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HARMONY-6590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12891974#action_12891974 ] deven you commented on HARMONY-6590: ------------------------------------ 2010/7/23 Tim Ellison (JIRA) osw.flush() has no problem, it does not call encoder.flush(), the problem is in the osw.close() which directly call encoder.flush() without checking the prerequisites. If you only keep the osw.close() as below: public static void main(String[] args) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bos, new MyCharsetEncoder()); osw.close(); Then harmony trunk will throw IllegalStateException now (since HARMONY-6594 has been applied), meanwhile RI5/RI6 won't throw this exception. HARMONY-6590 just fix this regression caused by HARMONY-6594. Thanks a lot! > [classlib][luni]A issue about CharsetEncoder.flush() in the OutputStreamWriter.close() > -------------------------------------------------------------------------------------- > > Key: HARMONY-6590 > URL: https://issues.apache.org/jira/browse/HARMONY-6590 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 5.0M14 > Reporter: deven you > Assignee: Tim Ellison > Attachments: HARMONY-6590.diff > > Original Estimate: 96h > Remaining Estimate: 96h > > Today I read through the OutputStreamWrtier.close() code below: > public void close() throws IOException { > synchronized (lock) { > if (encoder != null) { > encoder.flush(bytes); > flush(); > out.flush(); > out.close(); > encoder = null; > bytes = null; > } > } > } > I remember the java spec says for the CharsetEncoder.flush(): IllegalStateException - If the previous step of the current encoding operation was an invocation neither of the reset method nor of the three-argument encode method with a value of true for the endOfInput parameter. > Obviously OutputStreamWrtier.close() does not check this prerequisite before invoking the encoder.flush(bytes). So I write a test case[1] to check this issue but it passed, I think it is because our CharsetEncoder.flush() does not follow the spec. > Though I think our OutputStreamWrtier.close() should modify to follow the spec. I have put the patch[1] on this jira. > And I will also look into the CharsetEncoder.flush() to investigate this problem. > [1] see the attached patch -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.