# HG changeset patch # User jmanson # Date 1404335657 25200 # Node ID 4d33af5975a5f6bdd7d2dd75f6d9aa8919bdd2cf # Parent 5d63cd3696d6e73320616a3d703d0261b6fad2aa 8048840: File.createTempFile has uninformative failure message Reviewed-by: martin, alanb diff -r 5d63cd3696d6 -r 4d33af5975a5 jdk/src/share/classes/java/io/File.java --- 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"; diff -r 5d63cd3696d6 -r 4d33af5975a5 jdk/test/java/io/File/NulFile.java --- 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");