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

Printing to File does not throw any error when the specified file is Read-Only

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0, 1.4.0
    • client-libs
    • 2d
    • generic, x86
    • generic, windows_nt

      I am setting the destination as FILE using JobAttributes API and I am setting a file name also. This file already exists in the source directory and it is Read-Only. I am printing some data to the above specified file using one of the print dialogs or directly. When using the print dialogs, overwrite warning dialog is shown since the specified file name already exists in the destination dir. When the user clicks 'Yes' for the overwrite option, the specified file is unchanged and no error is thrown. Basically no action is taken when the file is read only. Same issue arises when there is already one file 'out.prn' (the default file name set) with read-only access in the default dir.

      Any file-save dialog will throw an error when the chosen file is read-only and I expect the Printing file dialog also to behave in the same way.
      This is reproducible on Solaris as well as Windows using JDK1.4 +.
      In JDK1.3, 1.3.1 an error dialog is shown to the user informing that the specified file could not be created.

      How to reproduce:
      I have attached a sample code. Save it and compile it. Create a text file 'praveen.prn' in the same dir where you have saved this source file. Run the sample code. You would see a frame with 3 buttons. Choose the dialog and click 'OK' in the dialog. (or choose 'no dlg'). You will get a file dialog defaulted with this file name and you will get a overwrite dialog also. Check the contents of the file you created once the overwrite dialog is disposed. If it is unchanged and if you don't see any error dialog, then the bug is reproduced.

      I tested this on Solaris 8, Win NT and Win XP.

      Here is the details about the PIT build on which testing is carried out:
      java version "2d-jcg-win-01-15-May-03.tiger"
      Java(TM) 2 Runtime Environment, Standard Edition (build 2d-jcg-win-01-15-May-03.tiger)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b06, mixed mode)

      ==============================================================================
      On JDK1.3, 1.3.1 the expected error is thrown only in case of Solaris and some other internal error is thrown on Win32.
      This is error is applicable even in few other cases:

      1. When the file name contains a location which the user does not have write access. For example if the location is specified as '/cdrom/praveen.ps' then the same error must be thrown as no file can be created in the above dir.
      2. When the file name is invalid or contains some junk characters which can not be part of a file name.

      I have attached a text file with a list of observations on solaris 8 and Win NT with various builds.


      ###@###.### 2003-05-22

            jgodinez Jennifer Godinez (Inactive)
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: