From c2dd346b48f4bac30f6ec52e41b1759c83a21e3d Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Fri, 9 Feb 2001 04:01:59 +0000 Subject: [PATCH] OutputStreamWriter.java: (flush, writeChars): Throw IOException if stream closed. * java/io/OutputStreamWriter.java: (flush, writeChars): Throw IOException if stream closed. From-SVN: r39559 --- libjava/ChangeLog | 3 +++ libjava/java/io/OutputStreamWriter.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 981c0ed64c1..6848231aa96 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -9,6 +9,9 @@ * java/lang/Float.java: As above. (floatToRawIntBits): New method. + * java/io/OutputStreamWriter.java: (flush, writeChars): Throw + IOException if stream closed. + 2001-02-08 Tom Tromey * java/lang/Float.java (parseFloat): New method. diff --git a/libjava/java/io/OutputStreamWriter.java b/libjava/java/io/OutputStreamWriter.java index e888c66a52e..41275985bea 100644 --- a/libjava/java/io/OutputStreamWriter.java +++ b/libjava/java/io/OutputStreamWriter.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999, 2000 Free Software Foundation +/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation This file is part of libgcj. @@ -69,6 +69,9 @@ public class OutputStreamWriter extends Writer { synchronized (lock) { + if (out == null) + throw new IOException("Stream closed"); + if (wcount > 0) { writeChars(work, 0, wcount); @@ -97,6 +100,9 @@ public class OutputStreamWriter extends Writer private void writeChars(char[] buf, int offset, int count) throws IOException { + if (out == null) + throw new IOException("Stream closed"); + while (count > 0) { // We must flush if out.count == out.buf.length. -- 2.30.2