OutputStreamWriter flush patch

Mark Wielaard mark@klomp.org
Fri Jul 21 09:15:00 GMT 2006

Hi Tom,

On Thu, 2006-07-20 at 17:46 -0600, Tom Tromey wrote:
> Mark> Unfortunately that didn't work. I haven't debugged it yet, but attached
> Mark> is a small testcase that shows a NullPointerException which it shouldn't
> Mark> give. This might be something subtle gone wrong in the merge since
> Mark> OutputStreamWriter is an override in libgcj. (Note the name of the
> Mark> testcase is misleading it has nothing to do with the Charset used.)
> This fails on trunk.  That's annoying since I "fixed" a bug in this
> code recently.  I guess I over-fixed it back into brokenness.

OK, I see what you fixed. In flush() you want to make sure that
wrieChars() is always called so any encoders are also flushed. But the
work scratch area might still be null. This patch just makes sure that
it exists like in other places were it is used. This makes gcjwebplugin
work nicely.

2006-07-21  Mark Wielaard  <mark@klomp.org>

        * java/io/OutputStreamWriter.java (flush): Create work if null.




--- java/io/OutputStreamWriter.java     (revision 115595)
+++ java/io/OutputStreamWriter.java     (working copy)
@@ -203,6 +203,8 @@

        // Always write -- if we are close()ing then we want to make
        // sure the converter is flushed.
+       if (work == null)
+         work = new char[100];
        writeChars(work, 0, wcount);
        wcount = 0;

More information about the Java mailing list