PipedInputStream and PipedOutputStream

YAMAGUCHI Yuji yamag at distribution.co.jp
Tue Mar 16 10:27:05 PST 1999


Hi, all.

Here is a patch for PipedInputStream.java and PiepdOutputStream.java.
Attached is the test program.

Index: PipedInputStream.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/io/PipedInputStream.java,v
retrieving revision 1.3
diff -u -r1.3 PipedInputStream.java
--- PipedInputStream.java	1999/03/11 21:10:01	1.3
+++ PipedInputStream.java	1999/03/16 19:24:55
@@ -17,7 +17,7 @@
 public class PipedInputStream
   extends InputStream
 {
-	private PipedOutputStream src = null;
+	PipedOutputStream src = null;
 	final protected static int PIPE_SIZE = 512;
 	protected byte[] pipe = new byte[PIPE_SIZE];
 	protected int out = 0;
@@ -42,8 +42,10 @@
 	if (this.src != null) {
 		throw new IOException("already connected");
 	}
-	src.connect(this);
 	this.src = src;
+	if (src.sink == null) {
+		src.connect(this);
+	}
 	closed = false;
 }
 
Index: PipedOutputStream.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/io/PipedOutputStream.java,v
retrieving revision 1.2
diff -u -r1.2 PipedOutputStream.java
--- PipedOutputStream.java	1999/03/11 21:10:01	1.2
+++ PipedOutputStream.java	1999/03/16 19:24:57
@@ -13,7 +13,7 @@
 public class PipedOutputStream
   extends OutputStream
 {
-	private PipedInputStream sink = null;
+	PipedInputStream sink = null;
 
 public PipedOutputStream() {
 }
@@ -33,7 +33,9 @@
 		throw new IOException("already connected");
 	}
 	sink = snk;
-	sink.connect(this);
+	if (snk.src == null) {
+		sink.connect(this);
+	}
 }
 
 public void write(byte b[], int off, int len) throws IOException {

--
// YAMAGUCHI Yuji - yamag at distribution.co.jp -
// Freeware Distribution Services Co.,Ltd.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Main.java
Type: application/octet-stream
Size: 1849 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/19990317/39abbc4b/attachment-0003.obj 


More information about the kaffe mailing list