A DESCRIPTION OF THE REQUEST :
Invoking File.createTempFile() to create a temporary file, throws a very unhelpful IOException if the temporary DIRECTORY does not exist. The exception message doesn't tell you WHICH file/directory is not found, only:
java.io.IOException: No such file or directory
I would have expected:
java.io.IOException: No such file or directory: /temp
It seems the exception originates from the call to UnixFileSystem.createFileExclusively(). I also tested with the Windows equivalent, WinNTFileSystem, which does the same.
JUSTIFICATION :
It is unforgivable to report a file error, knowing what the file path/name is, and not reporting it in all exception messages!
It is very hard to debug if the initiating code is not under the developer's direct control, e.g. as in my example, where it is called by a Spring multipart file resolver running in Jetty:
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at org.eclipse.jetty.util.MultiPartInputStream$MultiPart.createFile(MultiPartInputStream.java:152)
...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Report as much detail as you have about the file name/path that was attempted, e.g.
java.io.IOException: No such file or directory: /temp
ACTUAL -
It only reports the general error, not the file name/path:
java.io.IOException: No such file or directory
---------- BEGIN SOURCE ----------
System.setProperty("java.io.tmpdir", "/nonexistent");
File f = File.createTempFile("boom", "");
---------- END SOURCE ----------
Invoking File.createTempFile() to create a temporary file, throws a very unhelpful IOException if the temporary DIRECTORY does not exist. The exception message doesn't tell you WHICH file/directory is not found, only:
java.io.IOException: No such file or directory
I would have expected:
java.io.IOException: No such file or directory: /temp
It seems the exception originates from the call to UnixFileSystem.createFileExclusively(). I also tested with the Windows equivalent, WinNTFileSystem, which does the same.
JUSTIFICATION :
It is unforgivable to report a file error, knowing what the file path/name is, and not reporting it in all exception messages!
It is very hard to debug if the initiating code is not under the developer's direct control, e.g. as in my example, where it is called by a Spring multipart file resolver running in Jetty:
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2024)
at org.eclipse.jetty.util.MultiPartInputStream$MultiPart.createFile(MultiPartInputStream.java:152)
...
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Report as much detail as you have about the file name/path that was attempted, e.g.
java.io.IOException: No such file or directory: /temp
ACTUAL -
It only reports the general error, not the file name/path:
java.io.IOException: No such file or directory
---------- BEGIN SOURCE ----------
System.setProperty("java.io.tmpdir", "/nonexistent");
File f = File.createTempFile("boom", "");
---------- END SOURCE ----------