JDK-4804606 : FileInputStream constructor deletes a file that lacks read permission
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.1
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-01-17
  • Updated: 2009-06-25
  • Resolved: 2003-03-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1_03 03Fixed
Description

Name: jl125535			Date: 01/16/2003


FULL PRODUCT VERSION :
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 :
 windows 2000 professional 5.00.2195 Service pack 3


A DESCRIPTION OF THE PROBLEM :
The FileInputStream constructor deletes a file that does not have read 
permission.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create the file testfile.txt.
2. Deny "read" to the file created in step 1.
  a. Right mouse click on the file and choose Properties.
  b. Go to the Security tab and uncheck Read permission for all users.
3. Run test program
4. The test will throw an exception and the file created in step 1 will be
   deleted

EXPECTED VERSUS ACTUAL BEHAVIOR :
FileInputStream should not delete the file which can not be read

ERROR MESSAGES :
E:\tmpjava\179827_deletefile>java FileTest
java.io.FileNotFoundException: testfile.txt (The system cannot find the file specified)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.*;

public class FileTest
{
    public static void main(String[] args)
    {
        try
        {
            FileInputStream file = new FileInputStream("testfile.txt");
        }
        catch (IOException e)
        {
            System.out.println(e.toString());
        }
    }
}
---------- END SOURCE ----------
(Review ID: 179827) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.1 1.4.1_03 FIXED IN: 1.4.1_03 INTEGRATED IN: 1.4.1_03
14-06-2004

EVALUATION I reproduced this in 1.4.1 but it no longer occurs in 1.4.2 because of the move to the createFile API. ###@###.### 2003-01-21 This bug should be fixed, if possible, in the next 1.4.1 update release. -- ###@###.### 2003/1/21
21-01-2003