Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 83533 invoked from network); 5 Aug 2009 19:29:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Aug 2009 19:29:32 -0000 Received: (qmail 42001 invoked by uid 500); 5 Aug 2009 19:29:39 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 41957 invoked by uid 500); 5 Aug 2009 19:29:39 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 41948 invoked by uid 99); 5 Aug 2009 19:29:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2009 19:29:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2009 19:29:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 144C623888E6; Wed, 5 Aug 2009 19:29:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090805192917.144C623888E6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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)