8048840: File.createTempFile has uninformative failure message
Reviewed-by: martin, alanb
--- a/jdk/src/share/classes/java/io/File.java Wed Jul 02 10:21:23 2014 -0700
+++ b/jdk/src/share/classes/java/io/File.java Wed Jul 02 14:14:17 2014 -0700
@@ -1997,8 +1997,10 @@
File directory)
throws IOException
{
- if (prefix.length() < 3)
- throw new IllegalArgumentException("Prefix string too short");
+ if (prefix.length() < 3) {
+ throw new IllegalArgumentException("Prefix string \"" + prefix +
+ "\" too short: length must be at least 3");
+ }
if (suffix == null)
suffix = ".tmp";
--- a/jdk/test/java/io/File/NulFile.java Wed Jul 02 10:21:23 2014 -0700
+++ b/jdk/test/java/io/File/NulFile.java Wed Jul 02 14:14:17 2014 -0700
@@ -602,7 +602,10 @@
try {
File.createTempFile(prefix, suffix, directory);
} catch (IllegalArgumentException ex) {
- if ("Prefix string too short".equals(ex.getMessage()))
+ String actual = ex.getMessage();
+ String expected = "Prefix string \"" + prefix +
+ "\" too short: length must be at least 3";
+ if (actual != null && actual.equals(expected))
exceptionThrown = true;
} catch (IOException ioe) {
System.err.println("IOException happens in testCreateTempFile");