org.apache.axiom.om.impl.MIMEOutputUtils complete method does not flush output Stream. End MIMEBoundary is not flushed to output stream. -----------------------------------------------------------------------------------------------------------------------------------------
Key: WSCOMMONS-165 URL: https://issues.apache.org/jira/browse/WSCOMMONS-165 Project: WS-Commons Issue Type: Bug Components: AXIOM Environment: JDK 1.5.0_09, Resin 3.0.21 or Tomcat 5.5, axis2-1.1.1, windows Reporter: Rob Sutter Priority: Blocker The bug occurs while running a MTOM example that delivers MTOM attachments to the client. The client calls the service and the service returns an attachment via MTOM. The code worked correctly using axis2server but when deployed on either Tomcat or Resin the response would exclude the END MIMEBoundary (--MIMEBoundary--). This would cause various kinds of unwanted behaviors like adding random bytes to the attachment, cached attachments would grow without limit etc. It appears the problem occurs because the complete method in MIMEOutputUtils never flushes the output stream causing the END MIMEBoundary to get truncated. Note the END MIME Boundary is written to the stream it just never gets flushed. Adding flush to either the complete method as seen below fixes the problem. public static void complete(OutputStream outStream, StringWriter writer, LinkedList binaryNodeList, String boundary, String contentId, String charSetEncoding,String SOAPContentType) { try { startWritingMime(outStream, boundary); javax.activation.DataHandler dh = new javax.activation.DataHandler(writer.toString(), "text/xml; charset=" + charSetEncoding); MimeBodyPart rootMimeBodyPart = new MimeBodyPart(); rootMimeBodyPart.setDataHandler(dh); rootMimeBodyPart.addHeader("content-type", "application/xop+xml; charset=" + charSetEncoding + "; type=\""+SOAPContentType+"\";"); rootMimeBodyPart.addHeader("content-transfer-encoding", "binary"); rootMimeBodyPart.addHeader("content-id","<"+contentId+">"); writeBodyPart(outStream, rootMimeBodyPart, boundary); Iterator binaryNodeIterator = binaryNodeList.iterator(); while (binaryNodeIterator.hasNext()) { OMText binaryNode = (OMText) binaryNodeIterator.next(); writeBodyPart(outStream, createMimeBodyPart(binaryNode .getContentID(), (DataHandler) binaryNode .getDataHandler()), boundary); } finishWritingMime(outStream); //ADDED FLUSH HERE TO FLUSH OUTSTREAM outStream.flush(); } catch (IOException e) { throw new OMException("Error while writing to the OutputStream.", e); } catch (MessagingException e) { throw new OMException("Problem writing Mime Parts.", e); } } NOTE: I did not verify why it works correctly on axis2server but I suspect it is because it DOES NOT use the AxisServlet that is used when the axis2 is deployed on a real servlet container. -- 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]