Patch: java.io.PrintStream - PR/13176

Michael Koch konqueror@gmx.de
Sat Dec 6 20:07:00 GMT 2003


On Sat, Dec 06, 2003 at 05:53:18PM +0100, Mark Wielaard wrote:
> Hi,
> 
> On Fri, 2003-12-05 at 18:22, Michael Koch wrote:
> > On Fri, Dec 05, 2003 at 04:50:48PM +0100, Mark Wielaard wrote:
> > > On Fri, 2003-12-05 at 16:32, Michael Koch wrote:
> > > > On Fri, Dec 05, 2003 at 12:55:30AM +0100, Mark Wielaard wrote:
> > > > > > @@ -435,6 +522,10 @@
> > > > > >          if (auto_flush && (oneByte == '\n'))
> > > > > >            flush ();
> > > > > >        }
> > > > > > +    catch (InterruptedIOException iioe)
> > > > > > +      {
> > > > > > +        Thread.currentThread ().interrupt ();
> > > > > > +      }
> > > > > >      catch (IOException e)
> > > > > >        {
> > > > > >          setError ();
> > > > > 
> > > > > How/why does this work and why do we need to do this?
> > > > 
> > > > After looking closer into this I removed that part of the patch. It was
> > > > removed in revision 1.19 which fixed an PR.
> > > 
> > > Since you didn't remove it from flush(), close() and print() I assume it
> > > is till needed there?
> > 
> > I dont know if its needed but doesnt seem to be wrong according to the
> > testcase in PR/11778.
> > 
> > > How/Why does it work?
> > 
> > It uses always the current OutputStream object in "out". That way a
> > subclass of PrintStream can always set a new object to it. The old
> > implementation using PrintWriter could only use the object set to out
> > during constructor execution because it gave a reference to the
> > PrintWriter constructor.
> 
> OK. I understand that. I just don't understand why the catching of
> InterruptedIOException and the calling Thread.interrupt() is needed in
> the above methods, but not in the method were you say you removed it
> again. It looks like for example print() can be interrupted, a
> InterruptedIOException is thrown from natFileDescriptor who notices
> that, but we catch it in print() and just return with as only indication
> that something strange happened the fact that Thread.interrupted() will
> return true. Is that on purpose?

I dont really know. Perhaps we should ask Bryce. He removed the other
ones. I cc'ed him now.



Michael



More information about the Java-patches mailing list