harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r438387 - in /incubator/harmony/enhanced/classlib/trunk/modules/logging/src: main/java/java/util/logging/FileHandler.java test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
Date Wed, 30 Aug 2006 06:07:10 GMT
Author: pyang
Date: Tue Aug 29 23:07:10 2006
New Revision: 438387

URL: http://svn.apache.org/viewvc?rev=438387&view=rev
Log:
Patch applied for HARMONY-1299 ([classlib][logging] new FileHandler("") throws unexpected
NullPointerException)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
    incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java?rev=438387&r1=438386&r2=438387&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java
Tue Aug 29 23:07:10 2006
@@ -412,8 +412,11 @@
      * 								
      */
     public FileHandler(String pattern) throws IOException {
-        if(null == pattern || "".equals(pattern)){ //$NON-NLS-1$
+        if(null == pattern){ 
             throw new NullPointerException("Pattern cannot be empty"); //$NON-NLS-1$
+        }
+        if("".equals(pattern)){
+            throw new IllegalArgumentException();
         }
         init(pattern, null, new Integer(DEFAULT_LIMIT), new Integer(
                 DEFAULT_COUNT));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java?rev=438387&r1=438386&r2=438387&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/FileHandlerTest.java
Tue Aug 29 23:07:10 2006
@@ -330,15 +330,25 @@
 		assertFileContent(TEMPPATH, "testLimitCount0.0",
 				new LogRecord[] { rs[9] }, handler.getFormatter());
 		
+        FileHandler h1 = null;
+        FileHandler h2 = null;
         try {
             File logDir = new File("log");
             reset("log",""); 
             logDir.mkdir();
-            FileHandler h1 = new FileHandler("log/a", 0, 1);
+            h1 = new FileHandler("log/a", 0, 1);
             assertNotNull(h1);
-            FileHandler h2 = new FileHandler("log/a", 0, 1, false);
+            h2 = new FileHandler("log/a", 0, 1, false);
             assertNotNull(h2);
         } finally {
+            try{
+                h1.close();
+            }catch(Exception e){
+            }
+            try{
+                h2.close();
+            }catch(Exception e){
+            }
             reset("log", "");
         }	
 	}
@@ -525,10 +535,12 @@
 		} catch (NullPointerException e) {
 		}
 		try {
-			new FileHandler("");
-			fail("should throw null exception");
-		} catch (NullPointerException e) {
-		}
+            // regression test for Harmony-1299
+            new FileHandler("");
+            fail("should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected 
+        }
 		try {
 			new FileHandler("%t/java%u", 0, 0);
 			fail("should throw IllegalArgumentException");



Mime
View raw message