harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (HARMONY-6590) [classlib][luni]A issue about CharsetEncoder.flush() in the OutputStreamWriter.close()
Date Tue, 27 Jul 2010 11:34:16 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Tim Ellison resolved HARMONY-6590.

    Fix Version/s: 5.0M15
       Resolution: Fixed

Thanks Deven.

Looking at the proposed patch, we call encoder.flush() but don't look at the return code.

The spec says:
"If this method completes successfully then it returns CoderResult.UNDERFLOW. If there is
insufficient room in the output buffer then it returns CoderResult.OVERFLOW. If this happens
then this method must be invoked again, with an output buffer that has more room, in order
to complete the current encoding operation. "

I modified the code to do this, so please check you agree.  I also renamed the local variable
to make it clear what was going to be flushed.

The patch was applied at r979647.  Please verify this fixes the issue for you.

> [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
>             Fix For: 5.0M15
>         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.

View raw message