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 "Stefano Bagnara (JIRA)" <se...@james.apache.org> on 2008/02/24 23:09:15 UTC
[jira] Updated: (MIME4J-38) writeTo Implementation in Multipart is
broken.
[ https://issues.apache.org/jira/browse/MIME4J-38?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefano Bagnara updated MIME4J-38:
----------------------------------
Affects Version/s: 0.3
Please make sure you write the version you are reporting the bug against.
> writeTo Implementation in Multipart is broken.
> -----------------------------------------------
>
> Key: MIME4J-38
> URL: https://issues.apache.org/jira/browse/MIME4J-38
> Project: Mime4j
> Issue Type: Bug
> Affects Versions: 0.3
> Environment: Java 1.6
> Reporter: Aljoscha Rittner
> Assignee: Robert Burrell Donkin
> Fix For: 0.4
>
>
> This is a typical mixed-buffered/nonbuffered-Stream Bug ;-)
> This is the implementation in writeTo:
> ---------------------------------------------------------------------------
> BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, CharsetUtil.getCharset(getCharset())),8192);
>
> writer.write(getPreamble() + "\r\n");
> for (int i = 0; i < bodyParts.size(); i++) {
> writer.write(boundary + "\r\n");
> ((BodyPart) bodyParts.get(i)).writeTo(out);
> }
> writer.write(getEpilogue() + "\r\n");
> writer.write(boundary + "--" + "\r\n");
> ---------------------------------------------------------------------------
> But all writer.write (...) Strings get lost in the buffer. The non buffered writes throw the OutputStreamWriter are ok. This writeTo method creates Multipart-Messages without any boundary.
> A mix with buffered and non buffered streams is very danger. This is the right (but ugly) implementation:
> ---------------------------------------------------------------------------
> writer.write(getPreamble() + "\r\n");
> writer.flush();
> for (int i = 0; i < bodyParts.size(); i++) {
> writer.write(boundary + "\r\n");
> writer.flush();
> ((BodyPart) bodyParts.get(i)).writeTo(out);
> }
> writer.write(getEpilogue() + "\r\n");
> writer.write(boundary + "--" + "\r\n");
> writer.flush();
> ---------------------------------------------------------------------------
> best regards,
> josh.
--
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