james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "GX GLIX" <mailme...@hotmail.com>
Subject Re: [mime4j] null charset error
Date Fri, 04 May 2007 10:02:56 GMT
Hi Stefano

Sorry about that.. I made the mistake of switching to windows live (beta) 
and it screwed thing up..
hope this is clearer

GX

>From: Stefano Bagnara <apache@bago.org>
>Reply-To: "James Developers List" <server-dev@james.apache.org>
>To: James Developers List <server-dev@james.apache.org>
>Subject: Re: [mime4j] null charset error
>Date: Fri, 04 May 2007 11:19:36 +0200
>
>This message come through totally unformatted.
>I formatted it and opened a JIRA issue [1] so we can track it.
>
>Thank you,
>Stefano
>
>[1] http://issues.apache.org/jira/browse/MIME4J-12
>
>GX GLIX ha scritto:
> >
Hi all

I sincerely apologise for the delay, I have had other priorities and had to 
put this aside till now, after futher debugging I have come across the cause 
of the java.io.IOException: Bad file descriptor error.

In the file /org/mime4j/message/Header.java the following code is found

public void writeTo(OutputStream out) throws IOException {
        String charString = ((ContentTypeField) 
getField(Field.CONTENT_TYPE)).getCharset();

        BufferedWriter writer = new BufferedWriter(new 
OutputStreamWriter(out, CharsetUtil.getCharset(charString)),8192);
        writer.write(toString()+ "\r\n");
        writer.flush();
        writer.close();
    }

as you can see the output stream is closed here. This is cause of the 
IOException as the stream is used later again for writing.
I tried commenting the writer.close(); call and it worked fine, however I 
dont know what the implications of this may be.

The case I am facing is a multipart message which calls the writeTo method 
below

    public void writeTo(OutputStream out) throws IOException {
        getHeader().writeTo(out);

        Body body = getBody();
        if (body instanceof Multipart) {
            Multipart mp = (Multipart) body;
            mp.writeTo(out);
        } else {
            body.writeTo(out);
        }
    }

when getHeader().writeTo(out); is called the stream is closed and when 
mp.writeTo(out); is called the exception is throw as the stream is closed.

Regards
GX


> >From: Norman Maurer <norman@apache.org>> >Reply-To: "Jam
>es Developers List" <server-dev@james.apache.org>> >To: James Developers 
>List <server-dev@james.apache.org>> >Subject: Re: [mime4j] null charset 
>error> >Date: Tue, 24 Apr 2007 15:36:34 +0200> >> >Hi GX,> >>
>what JDK and 
>OS you using? I found some intressting stuff:> >> 
> >http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6322678> 
> >http://256.com/gray/docs/misc/java_bad_file_descriptor_close_bug.shtml> 
> >> >bye> >Norman> >> >> >GX GLIX schrieb:> > >
Hi All> > >> > > I am 
>getting a "Null charset name" error during parsing, it seems that> > > 
>getCharset(String charsetName) is passed an empty string... I tried> > > 
>the following hack to fix it:> > >> > > ..........> > >   
public static 
>java.nio.charset.Charset getCharset(String> > > charsetName) {> > >
       
>if(charsetName == null)> > >            charsetName = "ISO8859-1";> > >
    
>    java.nio.charset.Charset c => > > 
>java.nio.charset.Charset.forName(charsetName);> > > ............> > >>
> > 
>now the result is :> > >> > > java.i
>o.IOException: Bad file descriptor> > >     at 
>java.io.FileOutputStream.writeBytes(Native Method)> > >     at 
>java.io.FileOutputStream.write(FileOutputStream.java:260)> > >     at> >
> 
>sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)> > >  
>    at> > > > 
> >sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(StreamEncoder.java:404)> 
> > >> > >     at> > > 
>sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:408)> > >   
>   at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)> > >     at 
>java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)> > >     at 
>java.io.BufferedWriter.flush(BufferedWriter.java:230)> > >     at 
>org.mime4j.message.Header.writeTo(Header.java:152)> > >     at 
>org.mime4j.message.BodyPart.writeTo(BodyPart.java:39)> > >     at 
>org.mime4j.message.Multipart.writeTo(Multipart.java:178)> > >     at 
>org.mime4j.message.Message.writeTo(Message.java:91)> > > any ideas anyone?>

> > >> > > _______________________________________________
>__________________> > > FREE pop-up blocking with the new MSN Toolbar - get 
>it now!> > > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/>

> > >> > >> > > 
>---------------------------------------------------------------------> > > 
>To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org> > > For 
>additional commands, e-mail: server-dev-help@james.apache.org> > >> > >>
> 
> > !DSPAM:1,462c94fb324321289648189!> > >> > >> >> >>

> >---------------------------------------------------------------------> 
> >To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org> >For 
>additional commands, e-mail: server-dev-help@james.apache.org> >> > 
>_________________________________________________________________> Express 
>yourself instantly with MSN Messenger! Download today it's FREE! > 
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/> > > 
>---------------------------------------------------------------------> To 
>unsubscribe, e-mail: server-dev-unsubscribe@james.ap
>ache.org> For additional commands, e-mail: 
>server-dev-help@james.apache.org>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
>For additional commands, e-mail: server-dev-help@james.apache.org
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message