You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexei Zakharov (JIRA)" <ji...@apache.org> on 2007/03/02 13:46:51 UTC

[jira] Commented: (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:comment-tabpanel#action_12477283 ] 

Alexei Zakharov commented on HARMONY-3085:
------------------------------------------

Hi Mikhail,
I have a couple of comments to your patch. IMO it is not awfully correct to let the method with name getPageSize return a value that really is not a size of the page. This can cause issues in the future. Can we add some other function like getAllocationGranularitySize and then use *it* in FileChannelImpl.mapImpl()? Alternatively we can at least rename getPageSize().

> [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
>         Assigned To: Alexei Zakharov
>         Attachments: H-3085.patch, 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.