harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-849) [classlib][nio] FileChannel.read(ByteBuffer[] dsts) returns incorrect value and doesn't set the position of ByteBuffer[] in some cases.
Date Wed, 12 Jul 2006 08:29:29 GMT
[classlib][nio] FileChannel.read(ByteBuffer[] dsts) returns incorrect value and doesn't set
the position of ByteBuffer[] in some cases.
---------------------------------------------------------------------------------------------------------------------------------------

         Key: HARMONY-849
         URL: http://issues.apache.org/jira/browse/HARMONY-849
     Project: Harmony
        Type: Bug

  Components: Classlib  
    Reporter: Andrew Zhang


FileChannel.read(ByteBuffer[] dsts) returns incorrect value and doesn't set the position of
ByteBuffer[] in some cases.

Following test reproduces the bug:

    public void test_read$LByteBuffer() throws Exception {
        final int CAPACITY = 64;
        final String content = "TEST CONTENT";
        final long contentLength = content.length();
        
        File file = File.createTempFile("File_of_readOnlyFileChannel", "tmp");
        FileOutputStream fos = new FileOutputStream(file);
        try {
            fos.write(content.getBytes());
        } finally {
            fos.close();
        }
        ByteBuffer[] readBuffers = new ByteBuffer[2];
        readBuffers[0] = ByteBuffer.allocate(CAPACITY);
        readBuffers[1] = ByteBuffer.allocate(CAPACITY);
        FileChannel filechannel = new FileInputStream(file).getChannel();
        long readCount = filechannel.read(readBuffers);
        // Harmony fails on following two assertions
        assertEquals(contentLength, readCount);
        assertEquals(contentLength, readBuffers[0].position());
    }

The test passes against RI while fails against Harmony.

I'll upload a patch to fix the problem soon. 

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


Mime
View raw message