harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r801377 - in /harmony/enhanced/classlib/branches/java6/modules/luni/src: main/java/java/io/PipedReader.java main/java/java/io/PipedWriter.java test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java
Date Wed, 05 Aug 2009 19:29:16 GMT
Author: hindessm
Date: Wed Aug  5 19:29:16 2009
New Revision: 801377

URL: http://svn.apache.org/viewvc?rev=801377&view=rev
Log:
Applying trivially modified version of patch from "[#HARMONY-6293]
[classlib][luni] PipedWriter.flush should throw IOException if pipe is
closed (Java 6 only)".

Modified:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedReader.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedWriter.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedReader.java?rev=801377&r1=801376&r2=801377&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedReader.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedReader.java
Wed Aug  5 19:29:16 2009
@@ -139,6 +139,7 @@
                 /* Release buffer to indicate closed. */
                 data = null;
             }
+            isClosed = true;
         }
     }
 
@@ -477,8 +478,11 @@
         }
     }
 
-    void flush() {
+    void flush() throws IOException {
         synchronized (lock) {
+            if (isClosed) {
+                throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
+            }
             lock.notifyAll();
         }
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedWriter.java?rev=801377&r1=801376&r2=801377&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedWriter.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PipedWriter.java
Wed Aug  5 19:29:16 2009
@@ -112,6 +112,12 @@
      */
     @Override
     public void flush() throws IOException {
+        synchronized(lock) {
+            if (closed) {
+                throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
+            }
+        }
+    	
         if (dest != null) {
             dest.flush();
         }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java?rev=801377&r1=801376&r2=801377&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java
Wed Aug  5 19:29:16 2009
@@ -144,6 +144,33 @@
         assertEquals("Failed to flush chars", "HelloWorld", new String(
                 reader.buf));
     }
+    
+    /**
+     * @tests java.io.PipedWriter#flush()
+     * Regression HARMONY-6293
+     */
+    public void test_flushAfterClose() throws Exception {
+    	
+    	pw = new PipedWriter();
+    	pw.close();
+    	try {
+            pw.flush();
+            fail("should throw IOException");
+        } catch (IOException e) {
+            // expected
+        }
+    	
+        PipedReader pr = new PipedReader();
+        pw = new PipedWriter(pr);
+        pr.close();
+	
+        try {
+            pw.flush();
+            fail("should throw IOException");
+        } catch (IOException e) {
+            // expected
+        }
+    }
 
     /**
      * @tests java.io.PipedWriter#write(char[], int, int)



Mime
View raw message