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

File.setExecutable silently fails if file does not exist

XMLWordPrintable

    • b18
    • generic
    • windows

      A DESCRIPTION OF THE PROBLEM :
      If the file does not exist, then setExecutable fails silently.
      According to the documentation:
      Sets the owner's or everybody's execute permission for this abstract pathname.
      Abstract pathname. Means, no matter whether it exists or not.
      So if the file is written after setting executable, at the end the file shall be executable.

      Accordingly for other setter methods.

      I think, the documentation shall mention the case of non existing file explicitly.
      I would prefer a return value false in this case.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Choose a filename for a non existing file
      File file = new File (<nonexisting>);
      boolean success = file.setExecutable(true, false);
      file.createNewFile();

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Prefer success == false but my issue is more documentation.
      ACTUAL -
      success == true, case not documented.

      ---------- BEGIN SOURCE ----------
      see above
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      various, e.g. creating the file before using setExecutable.

      FREQUENCY : always


            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: