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

Produce warning when user specified java.io.tmpdir directory doesn't exist

XMLWordPrintable

    • behavioral
    • low
    • It is a static block and runs once when it is loaded into JVM. It did not alter the original workflow.
    • Implementation

      Summary

      Print out warning message when user specified java.io.tmpdir does not exist

      Problem

      When the directory of java.io.tmpdir is used as a file directory, but it is not set properly, the java.io.IOException is thrown with a generic error message of " No such file or directory". This message would not be able to give a hint to the developer about the configuration of java.io.tmpdir. See JDK-8290313.

      Solution

      Add a static block of the code in the inner class TempDirectory of java.io.File.java and TempFileHelper.java. It will print out an error message when java.io.tmpdir is not a valid directory.

      Specification

      static block of the code inside inner class TempDirectory in File.java

       // print out the error message for java.io.tmpdir setting
              static {
                  if (tmpdir.isInvalid() || !fs.hasBooleanAttributes(tmpdir, FileSystem.BA_DIRECTORY)) {
                      System.err.println("WARNING: java.io.tmpdir location does not exist");
                  }
              }

      static block of the code inside class java.nio.file.TempFileHelper.java

        // print out the error message for java.io.tmpdir setting
          static {
              if (!Files.isDirectory(tmpdir)) {
                  System.err.println("WARNING: java.io.tmpdir location does not exist");
              }
          }

            wxiao Weibing Xiao
            wxiao Weibing Xiao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: