RFR 8048840: File.createTempFile has uninformative failure message
Jeremy Manson
jeremymanson at google.com
Wed Jul 2 00:02:33 UTC 2014
Here you go (far too lazy to generate a webrev for this. :) )
diff --git a/src/share/classes/java/io/File.java
b/src/share/classes/java/io/File.java
--- a/src/share/classes/java/io/File.java
+++ b/src/share/classes/java/io/File.java
@@ -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 --git a/test/java/io/File/NulFile.java b/test/java/io/File/NulFile.java
--- a/test/java/io/File/NulFile.java
+++ b/test/java/io/File/NulFile.java
@@ -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");
On Tue, Jul 1, 2014 at 4:46 PM, Martin Buchholz <martinrb at google.com> wrote:
>
>
>
> On Tue, Jul 1, 2014 at 4:39 PM, Jeremy Manson <jeremymanson at google.com>
> wrote:
>
>> If Martin's happy, I'm happy. Martin, should I regenerate the patch with
>> that wording?
>>
>
> Yeah - I will try to sponsor this change.
>
More information about the core-libs-dev
mailing list