You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vera Petrashkova (JIRA)" <ji...@apache.org> on 2007/01/30 13:13:33 UTC

[jira] Updated: (HARMONY-3085) [classlib][nio] FileChannel.transferTo() and FileChannel.map() throws IOException when used file is large and position is equal or greater than 4096

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

Vera Petrashkova updated HARMONY-3085:
--------------------------------------

    Attachment: testFileChannel.zip

testFileChannel.zip contains testFileChannel source code, class file and from.txt file for mapping and
transfering

> [classlib][nio] FileChannel.transferTo() and FileChannel.map() throws IOException when used file is large and position is equal or greater than 4096
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3085
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3085
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Windows
>            Reporter: Vera Petrashkova
>         Attachments: testFileChannel.zip
>
>
> Reliability tests
>     api.nio.channels.filechannel.CopyFilesTest
>     api.nio.channels.filechannel.FileChannelMapTest
> fail with IOException when "position" parameter in 
>     FileChannel.tansferTo(long position, long count, WritableByteChannel target)    and 
>     FileChannel.map(FileChannel.MapMode mode,  long position, long size)
> methods is equal or greater than 4096.
> The following test demonstrates this issue:
> ----------------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> public class testFileChannel {
>     public static void main (String[] argv) {
>         FileChannel from = null;
>         FileChannel to = null;
>         long pp = Integer.parseInt(argv[1]); 
>         long size = Integer.parseInt(argv[2]); 
>         try {
>             from = new FileInputStream(argv[0]).getChannel();
>             to = new FileOutputStream("to.txt").getChannel();
>         } catch (Throwable e) {
>             e.printStackTrace();
>             return;
>         }
>         System.err.println("=====transferTo test=====");
>         try {
>             from.position(pp); 
>             long transfered = from.transferTo(pp , size,  to);        
>             System.err.println("Test passed: trasfered == " +transfered);
>         } catch (Throwable e) {
>             System.err.println("Test failed ");
>             e.printStackTrace();
>         }
>         System.err.println("=====map test=====");
>         try {
>             from.position(pp); 
>             from.map(FileChannel.MapMode.READ_ONLY, pp,size);
>             System.err.println("Test passed ");
>         } catch (Throwable e) {
>             System.err.println("Test failed ");
>             e.printStackTrace();
>         }
>     }
> }
> ----------------------------
> 1) Create testFileChannel class
> 2) Run test using from.txt file from attachment and define position as 4095 and size parameter
>      java -cp . testFileChannel from .txt 4095 10
> =====transferTo test=====
> Test passed: trasfered == 10
> =====map test=====
> Test passed
> 3) Run test using from.txt file from attachment and define position as 4096 and size parameter
>      java -cp . testFileChannel from .txt 4096 10
> =====transferTo test=====
> Test failed
> java.io.IOException
>         at org.apache.harmony.luni.platform.OSMemory.mmap(OSMemory.java:544)
>         at org.apache.harmony.luni.platform.PlatformAddressFactory.allocMap(PlatformAddressFactory.java:37)
>         at org.apache.harmony.nio.internal.FileChannelImpl.mapImpl(FileChannelImpl.java:194)
>         at org.apache.harmony.nio.internal.ReadOnlyFileChannel.map(ReadOnlyFileChannel.java:87)
>         at org.apache.harmony.nio.internal.FileChannelImpl.transferTo(FileChannelImpl.java:446)
>         at testFileChannel.main(testFileChannel.java:20)
> =====map test=====
> Test failed
> java.io.IOException
>         at org.apache.harmony.luni.platform.OSMemory.mmap(OSMemory.java:544)
>         at org.apache.harmony.luni.platform.PlatformAddressFactory.allocMap(PlatformAddressFactory.java:37)
>         at org.apache.harmony.nio.internal.FileChannelImpl.mapImpl(FileChannelImpl.java:194)
>         at org.apache.harmony.nio.internal.ReadOnlyFileChannel.map(ReadOnlyFileChannel.java:87)
>         at testFileChannel.main(testFileChannel.java:31)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.