java.io.OutputStreamWriter: too small buffer

kaffe at rufus.w3.org kaffe@rufus.w3.org
Wed Mar 1 02:42:03 PST 2000


I posted this bug report through http://www.kaffe.org/cgi-bin/kaffe,
but it did not reach kaffe-bugs@kaffe.novare.net
because kaffe.novare.net said "550 <kaffe-bugs@kaffe.novare.net>
... Relaying denied."

I do not know whether this report was accepted by
the Kaffe Bug Tracking System, so I would like to send it to
this mailing list again.

From: ito@htk.hitachi-cable.co.jp
Date: Tue, 29 Feb 2000 03:05:11 -0600
Message-Id: <200002290905.DAA22964@dallas-ms-000.novare.net>
To: kaffe-bugs@www.kaffe.org
Subject: java.io.OutputStreamWriter: too small buffer

Full_Name: Ito Kazumitsu
Version: kaffe-1.0.5 (snap)
OS: Linux 2.0.38
Submission from: (NULL) (210.225.95.3)


The output buffer of java.io.OutputStreamWriter is too small to
safely run XT, the XSLT processor.  The following error occurs
when processing a XML document containing Japanese characters:

## o = 1017     ## oe = 1024    ## o = 1020     ## oe = 1024    ## o = 1023    
## oe = 1024    java.lang.ArrayIndexOutOfBoundsException
        at kaffe.io.CharToByteUTF8.convert(CharToByteUTF8.java:37)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:79)
        at com.jclark.xsl.sax.HTMLOutputHandler.flushBuf(HTMLOutputHandler.java:721)
        at com.jclark.xsl.sax.HTMLOutputHandler.endDocument(HTMLOutputHandler.java:732)
        at com.jclark.xsl.sax.ResultBase.end(ResultBase.java:line unknown, pc
0x8390dc5)
        at com.jclark.xsl.tr.SheetImpl.process(SheetImpl.java:line unknown, pc
0x83dccc7)
        at com.jclark.xsl.sax.XSLProcessorImpl.parse(XSLProcessorImpl.java:line
unknown, pc 0x8394bc4)
        at com.jclark.xsl.sax.Driver.transform(Driver.java:line unknown, pc
0x81f8c60)
        at com.jclark.xsl.sax.Driver.transformFile(Driver.java:line unknown, pc
0x81f5517)
        at com.jclark.xsl.sax.Driver.main(Driver.java:line unknown, pc
0x81e54c3)

where CharToByteUTF8.java is patched for debugging as follows:

==================================================================
$ diff -c ~/kaffe/kaffe-snap/libraries/javalib/kaffe/io/CharToByteUTF8.java
kaffe/io/CharToByteUTF8.java
*** /home/ito/kaffe/kaffe-snap/libraries/javalib/kaffe/io/CharToByteUTF8.java 
Sun Oct 10 05:09:48 1999
--- kaffe/io/CharToByteUTF8.java        Tue Feb 29 17:13:37 2000
***************
*** 22,27 ****
--- 22,29 ----
        int ie = fpos + flen;

        for (; i < ie && o < oe; i++) {
+               System.err.print("## o = " + o +"\t");
+               System.err.print("## oe = " + oe + "\t");
                  char chr = from[i];
                  if (chr >= '\u0001' && chr <= '\u007F') {
                        to[o++] = (byte)chr;
==================================================================

And enlarging the buffer, that is, applying the following
patch to OutputStreamWriter.java helps solve this problem
although this is nothing but a workaround.

==================================================================
diff -c ~/kaffe/kaffe-snap/libraries/javalib/java/io/OutputStreamWriter.java
java/io/OutputStreamWriter.java
*** /home/ito/kaffe/kaffe-snap/libraries/javalib/java/io/OutputStreamWriter.javFri
Aug 13 10:56:01 1999
--- java/io/OutputStreamWriter.java     Tue Feb 29 17:58:37 2000
***************
*** 15,21 ****
  public class OutputStreamWriter
    extends Writer
  {
!       private final static int BUFDEFAULT = 1024;
        private final static int MINMARGIN = 32;
        private OutputStream strm;
        private CharToByteConverter encoding;
--- 15,22 ----
  public class OutputStreamWriter
    extends Writer
  {
!       //private final static int BUFDEFAULT = 1024;
!       private final static int BUFDEFAULT = 8*1024;
        private final static int MINMARGIN = 32;
        private OutputStream strm;
        private CharToByteConverter encoding;
==================================================================




More information about the kaffe mailing list