From commits-return-32744-apmail-harmony-commits-archive=harmony.apache.org@harmony.apache.org Thu Apr 12 15:31:54 2007 Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 49456 invoked from network); 12 Apr 2007 15:31:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Apr 2007 15:31:53 -0000 Received: (qmail 22173 invoked by uid 500); 12 Apr 2007 15:31:59 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 22153 invoked by uid 500); 12 Apr 2007 15:31:59 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 22144 invoked by uid 99); 12 Apr 2007 15:31:59 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2007 08:31:59 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2007 08:31:52 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 972CB71407D for ; Thu, 12 Apr 2007 08:31:32 -0700 (PDT) Message-ID: <5377843.1176391892616.JavaMail.jira@brutus> Date: Thu, 12 Apr 2007 08:31:32 -0700 (PDT) From: "Alexei Zakharov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-3324) [classlib][nio] It is not possible to delete file after transferring data from it In-Reply-To: <14040870.1173269424213.JavaMail.root@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on 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.