harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vera Petrashkova (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it
Date Fri, 09 Mar 2007 09:54:24 GMT

    [ 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.


Mime
View raw message