logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: BUG Report [illegal call java.io.ByteArrayOutputStream.toString()]: msg#00002

Subject: Re: BUG Report [illegal call java.io.ByteArrayOutputStream.toString()]
hi *,

thanks to peter mikula's contributions to the submission module this issue has been fixed.

regards, uli.

Maverick Crank GRey wrote:
Good day/evening/night/morning, 
chiba-developer-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx


I tried chiba-0.9.6-src.zip and find out that:
===
Method toString():String of class java.io.ByteArrayOutputStream
Found usages ( 5 usages in 4 files )
    org.chiba.connectors.smtp ( in chiba-0.9.6\src ) ( 1 usage in 1 file )
        SMTPSubmissionHandler.java ( 1 usage )
            (196, 35) send(getURI(), stream.toString(), mediatype);
    org.chiba.xml.xforms.connector.http ( in chiba-0.9.6\src ) ( 4 usages in 3 
files )
        HTTPModelItemCalculator.java ( 1 usage )
            (154, 26) post(getURI(), stream.toString());
        HTTPModelItemValidator.java ( 1 usage )
            (154, 26) post(getURI(), stream.toString());
        HTTPSubmissionHandler.java ( 2 usages )
            (168, 39) post(getURI(), stream.toString(), mediatype);
            (172, 38) put(getURI(), stream.toString(), mediatype);
===
// IntelliJ IDEA (Pallada) (c)

Look at JavaDoc for java.io.ByteArrayOutputStream.toString()
===
 * @author  Arthur van Hoff
 * @version 1.46, 01/23/03
 * @since   JDK1.0
===
===
    /**
     * Converts the buffer's contents into a string, translating bytes into
     * characters according to the platform's default character encoding.
     *
     * @return String translated from the buffer's contents.
     * @since   JDK1.1
     */
    public String toString() {
        return new String(buf, 0, count);
    }
===

E.g.
1) You have instance of javax.servlet.http.HttpServletRequest.

2) Method getCharacterEncoding() for this instance returns "UTF-8", so
   servlet MUST return javax.servlet.http.HttpServletResponse in the
   same encoding.

3) Then you are using a code like this:
   ===
   ByteArrayOutputStream stream = new ByteArrayOutputStream();
   serialize(submission, instance, stream);
   ===
   in org.chiba.xml.xforms.connector.http.HTTPSubmissionHandler

4) After that you call
   ===
   stream.toString()
   ===
   and if JVM was started with system property file.encoding not equal
   to "UTF-8", we would have a _big_trouble_.

What do you thing about this?



--
Ulrich Nicolas Lissé


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285


<Prev in Thread] Current Thread [Next in Thread>