harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r431549 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/File.java main/java/org/apache/harmony/luni/util/ExternalMessages.properties test/java/tests/api/java/io/FileTest.java
Date Tue, 15 Aug 2006 07:16:26 GMT
Author: pyang
Date: Tue Aug 15 00:16:25 2006
New Revision: 431549

URL: http://svn.apache.org/viewvc?rev=431549&view=rev
Log:
Patch applied for HARMONY-1166 ([classlib][luni] File.createNewFile() method should throw
IOException when the File has an empty string in it's constructor)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java?rev=431549&r1=431548&r2=431549&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
Tue Aug 15 00:16:25 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1015,6 +1015,9 @@
 		SecurityManager security = System.getSecurityManager();
 		if (security != null)
 			security.checkWrite(path);
+        if(0 == path.length()) {
+            throw new IOException(org.apache.harmony.luni.util.Msg.getString("KA012")); //$NON-NLS-1$
+        }
 		int result = newFileImpl(properPath(true));
 		switch (result) {
 		case 0:

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=431549&r1=431548&r2=431549&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
Tue Aug 15 00:16:25 2006
@@ -302,5 +302,5 @@
 KA00e=Radix {0} is less than Character.MIN_RADIX or greater than Character.MAX_RADIX
 KA00f=Socket output is shutdown
 KA010=Cannot read back reference to unshared object
-KA011=No such file or directory
 KA011=Malformed reply from SOCKS server
+KA012=No such file or directory

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java?rev=431549&r1=431548&r2=431549&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/FileTest.java
Tue Aug 15 00:16:25 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -319,6 +319,19 @@
                 .compareTo(f1) < 0);
         assertTrue("f1.compareTo(f3) did not result in vale > 0", f1
                 .compareTo(f3) > 0);
+    }
+    
+    /**
+     * @tests java.io.File#createNewFile()
+     */
+    public void test_createNewFile_EmptyString() {
+        File f = new File("");
+        try {
+            f.createNewFile();
+            fail("should throw IOException");
+        } catch (IOException e) {
+            // expected
+        }
     }
 
 	/**



Mime
View raw message