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/03/07 13:10:24 UTC

[jira] Created: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

[classlib][nio] It is not possible to delete file after transferring data from it
---------------------------------------------------------------------------------

                 Key: HARMONY-3324
                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
             Project: Harmony
          Issue Type: Bug
            Reporter: Vera Petrashkova


When FileChannel was object was associated with some File
File.delete always returns false after transferring data from this file to another.
To reproduce this issue run the following test:
----------testFileChannel.java-------------------
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;

public class testFileChannel {
    public static void main (String[] argv) {        
        boolean isTrans = (argv.length > 0);
        int whatFrom = 0;
        if (isTrans) {
            whatFrom = Integer.parseInt(argv[0]);
        }

        FileChannel from = null;
        FileChannel to = null;
        File f = null;
        File f1 = null;
        boolean fDel = true;
        boolean f1Del = true; 
        try {
            f = new File("from.txt");
            if (f.exists()) {
                System.err.println("Delete from.txt : "+f.delete());
            }
            f1 = new File("to.txt");
            if (!f1.exists()) {
                f1.createNewFile();
            }
            try {
                from = new FileOutputStream(f).getChannel(); 
                byte [] b = {(byte)1, (byte)2};
                ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
                from.write(bb);              
                from.force(false);
            } catch (Throwable e) {
                System.err.println("Unexpected error");
                e.printStackTrace();
                return;
            } finally {
                if (from != null) {
                    from.close();
                }
            }
            to = null;
            from = null;
            try {
                from = new FileInputStream(f).getChannel(); 
                to = new FileOutputStream(f1).getChannel(); 
                if (isTrans) {
                    long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
                }
            } catch (Throwable e) {
                e.printStackTrace();
            } finally {
                if (from != null) {
                    from.close();
                }
                if (to != null) {
                    to.close();
                }
            }
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            if (f != null) {
                fDel = f.delete();
            }
            if (f1 != null) {
                f1Del = f1.delete();
            }
        }
        if (!fDel) {
            System.err.println("File "+f+" exists: "+f.exists());
        }
        if (!f1Del) {
            System.err.println("File "+f1+" exists:  "+f1.exists());
        }
        if (!fDel || !f1Del) {
            System.err.println("Test failed");
            return;
        }
        System.err.println("Test passed"); 
    }
}
--------------------
Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
But it fails when one of these methods is used.

java -cp . testFileChannel 
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
icensors, as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony
Test passed

java -cp . testFileChannel 0
java -cp . testFileChannel 1

Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
icensors, as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony
File from.txt exists: true
Test failed


This issue causes the failure of the following reliability test: 
    api.nio.channels.filechannel.CopyFilesTest
Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
It fails on the second iteration.


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


[jira] Commented: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12488650 ] 

Alexei Zakharov commented on HARMONY-3324:
------------------------------------------

On Windows it fails as described. I added some comments to Mikhail's patch and committed it at the revision 528443. Thanks Mikhail and Vera. Please verify that everything is ok.

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Assigned To: Alexei Zakharov
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Updated: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov updated HARMONY-3324:
-------------------------------------

    Patch Info: [Patch Available]

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Assigned: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-3324:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Assigned To: Alexei Zakharov
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Commented: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12488403 ] 

Alexei Zakharov commented on HARMONY-3324:
------------------------------------------

All tests pass for me on the most recent version of DRLVM on Linux. however, I'll try to run this on Windows too

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Assigned To: Alexei Zakharov
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Closed: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov closed HARMONY-3324.
------------------------------------


closed

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Assigned To: Alexei Zakharov
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Commented: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Vera Petrashkova (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12479548 ] 

Vera Petrashkova commented on HARMONY-3324:
-------------------------------------------

On RI and BEA used file can be deleted after trnsferring.
Test testFileChannel passes on RI and BEA whether ftransferTo[transferFrom] method is used or not.
See output:

java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)

Test passed

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))

Test passed


> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>            Reporter: Vera Petrashkova
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Updated: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-3324:
------------------------------------

    Attachment: H-3324.patch

Here is the fix for the issue + regression tests.

Fix description:
1) transferTo() and transferFrom() methods of FileChannelImpl are using map() function which prevents file from being deleted (note, that RI also could not delete the file after map() method was called). So, the memory should be unmaped at the end of these methods as it is used for the methods purposes only. I've used free() method to do the unmapping operations.
2) It seems that there was a bug in java.nio.MappedByteBufferAdapter.free() method which first frees the memory by itself bypassing DirectByteBuffer.free() method and only after that calling this method. As a result the following error was printed: "Memory Spy! Fixed attempt to free memory that was not allocated PlatformAddress[31981568]". Comments for DirectByteBuffer.free() method clearly says that "Note this is is possible that the memory is freed by code that reaches into the address and explicitly frees it 'beneith' us -- this is bad form.". So i've remove the explicit freeing of the memory in MappedByteBufferAdapter.free() method.

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Resolved: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-3324.
--------------------------------------

    Resolution: Fixed

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Assigned To: Alexei Zakharov
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Updated: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Varlamov updated HARMONY-3324:
-------------------------------------

    Component/s: Classlib

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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


[jira] Commented: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12488670 ] 

Mikhail Markov commented on HARMONY-3324:
-----------------------------------------

Thanks, Alexei! Applied as expected.

> [classlib][nio] It is not possible to delete file after transferring data from it
> ---------------------------------------------------------------------------------
>
>                 Key: HARMONY-3324
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3324
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vera Petrashkova
>         Assigned To: Alexei Zakharov
>         Attachments: H-3324.patch
>
>
> When FileChannel was object was associated with some File
> File.delete always returns false after transferring data from this file to another.
> To reproduce this issue run the following test:
> ----------testFileChannel.java-------------------
> import java.io.*;
> import java.nio.channels.FileChannel;
> import java.nio.ByteBuffer;
> public class testFileChannel {
>     public static void main (String[] argv) {        
>         boolean isTrans = (argv.length > 0);
>         int whatFrom = 0;
>         if (isTrans) {
>             whatFrom = Integer.parseInt(argv[0]);
>         }
>         FileChannel from = null;
>         FileChannel to = null;
>         File f = null;
>         File f1 = null;
>         boolean fDel = true;
>         boolean f1Del = true; 
>         try {
>             f = new File("from.txt");
>             if (f.exists()) {
>                 System.err.println("Delete from.txt : "+f.delete());
>             }
>             f1 = new File("to.txt");
>             if (!f1.exists()) {
>                 f1.createNewFile();
>             }
>             try {
>                 from = new FileOutputStream(f).getChannel(); 
>                 byte [] b = {(byte)1, (byte)2};
>                 ByteBuffer bb = ByteBuffer.allocateDirect(b.length).wrap(b);
>                 from.write(bb);              
>                 from.force(false);
>             } catch (Throwable e) {
>                 System.err.println("Unexpected error");
>                 e.printStackTrace();
>                 return;
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>             }
>             to = null;
>             from = null;
>             try {
>                 from = new FileInputStream(f).getChannel(); 
>                 to = new FileOutputStream(f1).getChannel(); 
>                 if (isTrans) {
>                     long pp = (whatFrom == 0 ? from.transferTo(0 , 2,  to) : to.transferFrom(from, 0 , 2)); 
>                 }
>             } catch (Throwable e) {
>                 e.printStackTrace();
>             } finally {
>                 if (from != null) {
>                     from.close();
>                 }
>                 if (to != null) {
>                     to.close();
>                 }
>             }
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (f != null) {
>                 fDel = f.delete();
>             }
>             if (f1 != null) {
>                 f1Del = f1.delete();
>             }
>         }
>         if (!fDel) {
>             System.err.println("File "+f+" exists: "+f.exists());
>         }
>         if (!f1Del) {
>             System.err.println("File "+f1+" exists:  "+f1.exists());
>         }
>         if (!fDel || !f1Del) {
>             System.err.println("Test failed");
>             return;
>         }
>         System.err.println("Test passed"); 
>     }
> }
> --------------------
> Test passes when java.nio.FileChannel.transferTo[transerFrom] is not invoked.
> But it fails when one of these methods is used.
> java -cp . testFileChannel 
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> Test passed
> java -cp . testFileChannel 0
> java -cp . testFileChannel 1
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its l
> icensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r515167, (Mar  7 2007), Windows/ia32/msvc 1310, release build
> http://incubator.apache.org/harmony
> File from.txt exists: true
> Test failed
> This issue causes the failure of the following reliability test: 
>     api.nio.channels.filechannel.CopyFilesTest
> Reliability test repeatedly tries to create temporary file, write some data to it, copy information to another files and delete the first file.
> It fails on the second iteration.

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