Duplicate :
|
Name: nt126004 Date: 11/25/2002 FULL PRODUCT VERSION : java version "1.4.1_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01) Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode) and java version "1.4.1" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21) Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode) FULL OPERATING SYSTEM VERSION : Microsoft Windows XP [Version 5.1.2600] A DESCRIPTION OF THE PROBLEM : On Windows, after opening all available file handles, an attempt to open a file using RandomAccessFile will delete the file you are attempting to open. The following simple test program creates 5000 files in a directory supplied on the command line and then attempts to open all of them at the same time. You will note at the pause that all of the files exist. After we have tried to open all of the files most of them will have been deleted. This does _not_ remove the files in version 1.4.0_02. The problem report is for java.io.RandomAccessFile. When just creating java.io.File objects the problem does _not_ occur. When opening the file using java.io.FileInputStream the files get deleted just like java.io.RandomAccessFile. The only way that I could open the files using java.io.DataInputStream was by using java.io.FileInputStream, which evidenced the problem. REGRESSION. Last worked in version 1.4 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1.Run the java program supplied. 2.At the pause, you will note that there have been 5000 files created. 3.You will get a bunch of errors unable to open file when file handles have been exausted. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED: All of the files created still exist. ACTUAL: Most of the files were deleted just by attempting to open them. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.io.*; import java.util.*; public class Test { public static void main (String []p_argv) { String file = p_argv[0]; int count = 5000; for (int i = 0; i < count; i++) { String f = file + "/tmp." + i; try { RandomAccessFile r = new RandomAccessFile(f,"rw"); r.close(); } catch (IOException e) { e.printStackTrace(System.err); System.exit(1); } } try { System.out.println("Files should all be created, press <RETURN> to continue:"); System.in.read(); } catch (IOException e) { // IGNORE... } List files = new LinkedList(); for (int i = 0; i < count; i++) { String f = file + "/tmp." + i; try { RandomAccessFile r = new RandomAccessFile(f,"rw"); files.add(r); } catch (IOException e) { e.printStackTrace(System.err); } } } } ---------- END SOURCE ---------- CUSTOMER WORKAROUND : No workaround available. (Review ID: 166491) ======================================================================