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-903) [classlib][nio] compatibility: java.nio.channels.FileChannel.write(ByteBuffer, long) throws different exception from RI.
Date Tue, 18 Jul 2006 03:07:13 GMT
[classlib][nio] compatibility: java.nio.channels.FileChannel.write(ByteBuffer, long) throws
different exception from RI.
------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-903
                 URL: http://issues.apache.org/jira/browse/HARMONY-903
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Andrew Zhang
            Priority: Minor


java.nio.channels.FileChannel.write(ByteBuffer, long) throws different exception from RI.

Following test reproduces the bug:
    public void test_writeLByteBufferJ_ReadOnly_Exception() throws Exception {
        File testFile = File.createTempFile("test", "tmp");
        testFile.deleteOnExit();
        FileChannel readOnlyFileChannel = new FileInputStream(testFile)
                .getChannel();

        ByteBuffer writeBuffer = null;
        readOnlyFileChannel.close();
        try {
            readOnlyFileChannel.write(writeBuffer, -1);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        writeBuffer = ByteBuffer.allocate(1);
        try {
            readOnlyFileChannel.write(writeBuffer, -1);
            fail("should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected
        }

        try {
            readOnlyFileChannel.write(writeBuffer, 0);
            fail("should throw NonWritableChannelException");
        } catch (NonWritableChannelException e) {
            // expected
        }
    }

The test passes against RI while fails against Harmony.

I'll upload a patch to fix this 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