You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Norman Maurer (JIRA)" <se...@james.apache.org> on 2007/05/04 19:34:15 UTC

[jira] Resolved: (MIME4J-12) WriteTo closes the outputstream too early (java.io.IOException: Bad file descriptor error)

     [ https://issues.apache.org/jira/browse/MIME4J-12?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Norman Maurer resolved MIME4J-12.
---------------------------------

    Resolution: Fixed
      Assignee: Norman Maurer

Remove the close

> WriteTo closes the outputstream too early (java.io.IOException: Bad file descriptor error)
> ------------------------------------------------------------------------------------------
>
>                 Key: MIME4J-12
>                 URL: https://issues.apache.org/jira/browse/MIME4J-12
>             Project: Mime4j
>          Issue Type: Bug
>    Affects Versions: 0.3
>            Reporter: Stefano Bagnara
>         Assigned To: Norman Maurer
>             Fix For: 0.3
>
>
> On server-dev, GX GLIX reported this:
> ---------------------------
> 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

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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