Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6364894

FileOutputStream is able to modify/write to read-only filessince Mustang-b63 (win)

XMLWordPrintable

    • b63
    • 6
    • b69
    • x86
    • windows_xp
    • Verified

      I have a read-only file and I am creating a FileOutputStream out of the read-only file. The FOS modifies the read-only file without any errors and make it '0' byte.

      This is reproducible only on WinXP, only since Mustang-b63. Not reproducible on Mustang-b59c (throws an exception). Not reproducible on Solaris. The file that I have overwritten is not modifiable even by native applications and they say the file is read-only but Java is able to modify it.

      I think this is a regression introduced by the following bug fixed in b63:
      6350200: FileOutputStream.open() throws FileNotFoundException for hidden file (win)

      This is a serious regression in Mustang-RC and java is not supposed to modify read-only files. Needs to be fixed ASAP.

      I have attached a sample test and a sample image. Save them in the same directory. Change the cup.png file to read-only (typically r--r--r--). Run the application and pass the file name as argument. You will see that the file is getting modified and becomes a '0' byte file after creation of FOS even though File.canWrite() returns false.

            jhangalsunw Jayalaxmi Hangal (Inactive)
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: