harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r429669 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
Date Tue, 08 Aug 2006 14:47:45 GMT
Author: pyang
Date: Tue Aug  8 07:47:44 2006
New Revision: 429669

URL: http://svn.apache.org/viewvc?rev=429669&view=rev
Log:
Fix for HARMONY-1093 ([classlib][luni] Problems in java.io.PipedInputStream.receive(int))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java?rev=429669&r1=429668&r2=429669&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
Tue Aug  8 07:47:44 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -299,34 +299,37 @@
 	 *             occurs.
 	 */
 	protected synchronized void receive(int oneByte) throws IOException {
-		if (buffer != null) {
-			/**
-			 * Set the last thread to be writing on this PipedInputStream. If
-			 * lastWriter dies while someone is waiting to read an IOException
-			 * of "Pipe broken" will be thrown in read()
-			 */
-			lastWriter = Thread.currentThread();
-			try {
-				while (buffer != null && out == in) {
-					notifyAll();
-					wait(1000);
-					if (lastReader != null && !lastReader.isAlive())
-						throw new IOException(org.apache.harmony.luni.util.Msg
-								.getString("K0076")); //$NON-NLS-1$
-				}
-			} catch (InterruptedException e) {
-				throw new InterruptedIOException();
-			}
-			if (buffer != null) {
-				if (in == -1)
-					in = 0;
-				buffer[in++] = (byte) oneByte;
-				if (in == buffer.length)
-					in = 0;
-				return;
+		if (buffer == null || isClosed) {
+		    throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0078")); //$NON-NLS-1$
+        }
+        if (lastReader != null && !lastReader.isAlive()){
+            throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0076")); //$NON-NLS-1$
+        }
+		/**
+		 * Set the last thread to be writing on this PipedInputStream. If
+		 * lastWriter dies while someone is waiting to read an IOException
+		 * of "Pipe broken" will be thrown in read()
+		 */
+		lastWriter = Thread.currentThread();
+		try {
+			while (buffer != null && out == in) {
+				notifyAll();
+				wait(1000);
+				if (lastReader != null && !lastReader.isAlive())
+					throw new IOException(org.apache.harmony.luni.util.Msg
+							.getString("K0076")); //$NON-NLS-1$
 			}
+		} catch (InterruptedException e) {
+			throw new InterruptedIOException();
+		}
+		if (buffer != null) {
+			if (in == -1)
+				in = 0;
+			buffer[in++] = (byte) oneByte;
+			if (in == buffer.length)
+				in = 0;
+			return;
 		}
-		throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0078")); //$NON-NLS-1$
 	}
 
 	synchronized void done() {



Mime
View raw message