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

(spec) File.createTempFile() should make it clear that it doesn't create the temporary directory

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.2, 6u20
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b04
    • CPU:
      x86
    • OS:
      windows_2000, windows_2008

      Description

      Name: rmT116609 Date: 04/11/2003


      A DESCRIPTION OF THE REQUEST :
      Please make File.createTempFile attempt to create parent directory.

      On Windows when a directory corresponding to the value of the temp directory property doesn't exist, an Exception is thrown: The system cannot find the path specified.
      Unix doesn't have this problem.

      Instead of throwing this exception it would be nicer to attempt parent.mkdirs 1st, to see if it can actually make this temp file.


      JUSTIFICATION :
      When using some ImageIO providers, they use null as the temp directory hence the property is used, which falsely assumes that the directory already exists. The end result is ImageIO always fails on these systems.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The parent directory getting created if it doesn't already exist and hence the temp file inside it also getting created.
      an Exception is thrown: The system cannot find the path specified.
      (takes time to find this as the exception gets changed and propagated so many times by ImageIO that the actual cause of the problem is no longer apparent)

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

      public class Test {
        public static void main(String[] args) throws IOException {
          File.createTempFile("Test", ".tmp", new File("c:/xxx"));
          System.out.println("Created");
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      call new File(System.getProperty("java.io.tmpdir")).mkdirs() before anything ever calls File.createTempFile
      (Review ID: 183674)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: