harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r572680 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/PrintStream.java test/api/common/tests/api/java/io/PrintStreamTest.java
Date Tue, 04 Sep 2007 13:44:35 GMT
Author: tellison
Date: Tue Sep  4 06:44:34 2007
New Revision: 572680

URL: http://svn.apache.org/viewvc?rev=572680&view=rev
Log:
Map illegal charset name to unsupported exception in PrintStream constructor.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java?rev=572680&r1=572679&r2=572680&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java Tue
Sep  4 06:44:34 2007
@@ -18,6 +18,7 @@
 package java.io;
 
 import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
 import java.security.AccessController;
 import java.util.Formatter;
 import java.util.IllegalFormatException;
@@ -118,7 +119,11 @@
             throw new NullPointerException();
         }
         this.autoflush = autoflush;
-        if (!Charset.isSupported(enc)) {
+        try {
+            if (!Charset.isSupported(enc)) {
+                throw new UnsupportedEncodingException(enc);
+            }
+        } catch (IllegalCharsetNameException e) {
             throw new UnsupportedEncodingException(enc);
         }
         encoding = enc;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java?rev=572680&r1=572679&r2=572680&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/PrintStreamTest.java
Tue Sep  4 06:44:34 2007
@@ -107,6 +107,19 @@
     }
 
     /**
+     * @tests java.io.PrintStream#PrintStream(java.io.OutputStream, boolean, String)
+     */
+    public void test_ConstructorLjava_io_OutputStreamZLjava_lang_String() {
+        try {
+            new PrintStream(new ByteArrayOutputStream(), false,
+                    "%Illegal_name!");
+            fail("Expected UnsupportedEncodingException");
+        } catch (UnsupportedEncodingException e) {
+            // expected
+        }
+    }
+
+    /**
      * @tests java.io.PrintStream#checkError()
      */
     public void test_checkError() throws Exception {



Mime
View raw message