This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
OutputStreamWriter flush patch
- From: Mark Wielaard <mark at klomp dot org>
- To: tromey at redhat dot com, java-patches at gcc dot gnu dot org
- Cc: Thomas Fitzsimmons <fitzsim at redhat dot com>, java at gcc dot gnu dot org, Andreas Tobler <toa at pop dot agri dot ch>
- Date: Fri, 21 Jul 2006 11:14:46 +0200
- Subject: OutputStreamWriter flush patch
- References: <1153356148.24618.5.camel@hermans.wildebeest.org> <44BF7D96.4080106@redhat.com> <1153401085.2590.34.camel@elsschot.wildebeest.org> <44BF849C.3050101@redhat.com> <1153425314.5640.9.camel@localhost.localdomain> <1153438622.5640.22.camel@localhost.localdomain> <m3k667hmah.fsf@localhost.localdomain>
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.
OK?
Cheers,
Mark
--- 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;