On 7/1/14 1:34 AM, Alan Bateman wrote:
On 01/07/2014 02:21, Jeremy Manson wrote:
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
@@ -1998,7 +1998,8 @@
          throws IOException
      {
          if (prefix.length() < 3)
-            throw new IllegalArgumentException("Prefix string too short");
+            throw new IllegalArgumentException("Prefix string too short: "
+
+                                               prefix);
I assume you meant to "+ prefix" here, in which case the change seems okay to
me. The update to the NulFile test seems okay too.

Ha! I was wondering about this too. Turns out that the trailing "+" on the "throw new" line was wrapped to the beginning of the next line, making it appear to be the addition of an extra, blank line.

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,8 @@
             try {
                 File.createTempFile(prefix, suffix, directory);
             } catch (IllegalArgumentException ex) {
-                if ("Prefix string too short".equals(ex.getMessage()))
+                String s = ex.getMessage();
+                if (s != null && s.startsWith("Prefix string too short"))
                     exceptionThrown = true;
             } catch (IOException ioe) {
                 System.err.println("IOException happens in
testCreateTempFile");

I'd advocate removing the string-testing logic from this catch-clause. I'm somewhat allergic to tests that make assertions about the contents of things like error messages. It generally doesn't add any value, but it increases maintenance effort -- like in this case.

s'marks

Reply via email to