harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessewil...@apache.org
Subject svn commit: r835181 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io: OutputStream.java OutputStreamWriter.java PrintStream.java PrintWriter.java Writer.java
Date Thu, 12 Nov 2009 01:01:24 GMT
Author: jessewilson
Date: Thu Nov 12 01:01:23 2009
New Revision: 835181

URL: http://svn.apache.org/viewvc?rev=835181&view=rev
Log:
Fixing PrintWriter.checkError() and PrintStream.checkError() to delegate to the underlying
PrintWriter/PrintStream as necessary.
Fixing PrintWriter.println(String) to call through the overridable no-args println() method.

Both of these behaviour changes bring us closer to compatibility with the RI.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintStream.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java?rev=835181&r1=835180&r2=835181&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java Thu
Nov 12 01:01:23 2009
@@ -118,4 +118,12 @@
      *             if an error occurs while writing to this stream.
      */
     public abstract void write(int oneByte) throws IOException;
+
+    /**
+     * Returns true if this writer has encountered and suppressed an error. Used
+     * by PrintStreams as an alternative to checked exceptions.
+     */
+    boolean checkError() {
+        return false;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java?rev=835181&r1=835180&r2=835181&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
Thu Nov 12 01:01:23 2009
@@ -302,4 +302,8 @@
             convert(chars);
         }
     }
+
+    @Override boolean checkError() {
+        return out.checkError();
+    }
 }

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=835181&r1=835180&r2=835181&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 Thu
Nov 12 01:01:23 2009
@@ -232,10 +232,13 @@
      * @see #setError()
      */
     public boolean checkError() {
-        if (out != null) {
-            flush();
+        OutputStream delegate = out;
+        if (delegate == null) {
+            return ioError;
         }
-        return ioError;
+
+        flush();
+        return ioError || delegate.checkError();
     }
 
     /**

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java?rev=835181&r1=835180&r2=835181&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PrintWriter.java Thu
Nov 12 01:01:23 2009
@@ -223,10 +223,13 @@
      * @see #setError()
      */
     public boolean checkError() {
-        if (out != null) {
-            flush();
+        Writer delegate = out;
+        if (delegate == null) {
+            return ioError;
         }
-        return ioError;
+
+        flush();
+        return ioError || delegate.checkError();
     }
 
     /**
@@ -373,16 +376,6 @@
     }
 
     /**
-     * Print a new line String onto the writer, flushing if autoflush enabled.
-     */
-    private void newline() {
-        print(lineSeparator);
-        if (autoflush) {
-            flush();
-        }
-    }
-
-    /**
      * Prints the string representation of the specified character array
      * to the target.
      * 
@@ -494,7 +487,10 @@
      */
     public void println() {
         synchronized (lock) {
-            newline();
+            print(lineSeparator);
+            if (autoflush) {
+                flush();
+            }
         }
     }
 
@@ -605,7 +601,7 @@
     public void println(String str) {
         synchronized (lock) {
             print(str);
-            newline();
+            println();
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java?rev=835181&r1=835180&r2=835181&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java Thu Nov
12 01:01:23 2009
@@ -242,4 +242,12 @@
         }
         return this;
     }
+
+    /**
+     * Returns true if this writer has encountered and suppressed an error. Used
+     * by PrintWriters as an alternative to checked exceptions.
+     */
+    boolean checkError() {
+        return false;
+    }
 }



Mime
View raw message