harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Strigun (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-33) java.nio.BufferOverflow exception while decoding ByteBuffer with UTF-16 charset
Date Wed, 18 Jan 2006 11:44:47 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-33?page=comments#action_12363090 ] 

Vladimir Strigun commented on HARMONY-33:
-----------------------------------------

Hi Paulex,

I can't reproduce IllegalStateException  with my fix and with next test:
import java.nio.*;
import java.nio.charset.*;

public class Harmony33 {

    public static void main(String[] args) {
        try{
            ByteBuffer bb = ByteBuffer.allocate(1); 
            bb.put(0,(byte)77); 
            CharsetDecoder utf16D = Charset.forName("UTF-16").newDecoder();
            CharBuffer cb = utf16D.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).decode(bb);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}


Possibly, you used not complete fix. My initial fix remove line "continue;" after checking
remaining value of CharBuffer. But if I don't remove "continue;" line after the check I get
same exception:
java.lang.IllegalStateException
        at java.nio.charset.CharsetDecoder.flush(Unknown Source)
        at java.nio.charset.CharsetDecoder.decode(Unknown Source)
        at Harmony33.main(Harmony33.java:11)

> java.nio.BufferOverflow exception while decoding ByteBuffer with UTF-16 charset
> -------------------------------------------------------------------------------
>
>          Key: HARMONY-33
>          URL: http://issues.apache.org/jira/browse/HARMONY-33
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Vladimir Strigun
>     Assignee: Geir Magnusson Jr
>     Priority: Minor

>
> If I try to decode ByteBuffer with lengh 1 using UTF-16 decoder unexpected java.nio.BufferOverflow
exception occured. Please see testcase below.
> import java.nio.*;
> import java.nio.charset.*;
> import junit.framework.TestCase;
> public class TestDecoder extends TestCase {
>     public static void main(String[] args) {
>         junit.textui.TestRunner.run(TestDecoder.class);
>     }
>     public static void testDecoder(){
>         try{
>             ByteBuffer bb = ByteBuffer.allocate(1); 
>             bb.put(0,(byte)77); 
>             CharsetDecoder utf16D = Charset.forName("UTF-16").newDecoder();
>             CharBuffer cb = utf16D.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).decode(bb);
>         }catch(Exception e){
>             fail("Exception occured: "+e);
>         }
>     }
> }
> Output on RI:
> .
> Time: 0,03
> OK (1 test)
> Output with Harmony:
> .F
> Time: 0,01
> There was 1 failure:
> 1) testDecoder(TestDecoder)junit.framework.AssertionFailedError: Exception occured: java.nio.BufferOverflowException
>         at TestDecoder.testDecoder(TestDecoder.java:20)
>         at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:211)
>         at TestDecoder.main(TestDecoder.java:10)
> FAILURES!!!
> Tests run: 1,  Failures: 1,  Errors: 0

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


Mime
View raw message