This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: yet another Piped* fix
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: yet another Piped* fix
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 21 Apr 2000 15:44:02 -0600
- Reply-To: tromey at cygnus dot com
Yet another java.io.Piped* fix. This is going in to Classpath as
well. Eventually (once we have more stuff merged) I'll probably just
start making changes in Classpath only and then do periodic merges.
2000-04-21 Tom Tromey <tromey@cygnus.com>
* java/io/PipedInputStream.java, java/io/PipedOutputStream.java:
Yet another new version from Classpath.
Tom
Index: java/io/PipedInputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/PipedInputStream.java,v
retrieving revision 1.5
diff -u -r1.5 PipedInputStream.java
--- PipedInputStream.java 2000/04/21 20:12:05 1.5
+++ PipedInputStream.java 2000/04/21 21:30:13
@@ -398,30 +398,19 @@
* If there is no data ready to be written, or if the internal circular
* buffer is full, this method blocks.
*
- * *****What is this method really supposed to do *********
+ * @param byte_received The byte to write to this stream
+ *
+ * @exception IOException if error occurs
+ *
*/
protected synchronized void
receive(int byte_received) throws IOException
{
- int orig_in = in;
-
- for (;;)
- {
- // Wait for something to happen
- try
- {
- wait();
- }
- catch(InterruptedException e) { ; }
-
- // See if we woke up because the stream was closed on us
- if (closed)
- throw new IOException("Stream closed before receiving byte");
-
- // See if a byte of data was received
- if (in != orig_in)
- return;
- }
+ // This is really slow, but it has the benefit of not duplicating
+ // the complicated machinery in receive(byte[],int,int).
+ byte[] buf = new byte[1];
+ buf[0] = (byte) (byte_received & 0xff);
+ receive (buf, 0, 1);
}
/*************************************************************************/
@@ -439,7 +428,7 @@
* @exception IOException If an error occurs
*/
synchronized void
-write(byte[] buf, int offset, int len) throws IOException
+receive(byte[] buf, int offset, int len) throws IOException
{
if (len <= 0)
return;
Index: java/io/PipedOutputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/PipedOutputStream.java,v
retrieving revision 1.5
diff -u -r1.5 PipedOutputStream.java
--- PipedOutputStream.java 2000/04/21 01:18:16 1.5
+++ PipedOutputStream.java 2000/04/21 21:30:13
@@ -1,5 +1,5 @@
/* PipedOutputStream.java -- Write portion of piped streams.
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -164,10 +164,7 @@
public synchronized void
write(int b) throws IOException
{
- byte[] buf = new byte[1];
- buf[0] = (byte)(b & 0xFF);
-
- snk.write(buf, 0, buf.length);
+ snk.receive (b);
}
/*************************************************************************/
@@ -188,7 +185,7 @@
public void
write(byte[] buf, int offset, int len) throws IOException
{
- snk.write(buf, 0, len);
+ snk.receive (buf, 0, len);
}
/*************************************************************************/