MTOMXMLStreamWriter flush() can cause attachments to be written at the wrong 
time
---------------------------------------------------------------------------------

                 Key: WSCOMMONS-231
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-231
             Project: WS-Commons
          Issue Type: Bug
            Reporter: Rich Scheuerle


Upgrades to MTOMXMLStreamWriter

Summary of Changes:
    1) Improve quality of the attachment writing code.
    2) Improve access to the OutputStream.
    3) JavaDoc improvements.
  

Problem Scenario 1:
    The MTOMXMLStreamWriter overrides the XMLStreamWriter.flush() method.  It 
uses the flush() as 
    a trigger to write out the attachments.  However, if flush() is invoked 
inside the SOAPPart or 
    if it is called multiple times, the output message is corrupted.  

Solution:
    Upgraded the methods to keep track of writer state information.  For 
example, the writer
    keeps track of when the endDocument is written.  The flush() method is 
changed to write
    attachments after the SOAPPart is complete.  I also added code to ensure 
that the attachments
    are written only one time.

---------------------------------
Problem Scenario 2:
    The MTOMXMLStreamWriter exposes a getOutputStream() method.  This method 
provides access
    to the OutputStream (if available) so that an underlying data source can 
write directly to 
    the stream.  In many cases it is more performant to write to the 
OutputStream instead of writing
    through the XMLStreamReader interface.  In the current implementation, the 
OutputStream is not 
    available if the SOAPPart xml is being buffered.

Solution:
    Changed the code to buffer the SOAPPart xml in a ByteArrayOutputStream.  
The getOutputStream() method
    provides access to this buffered stream.  Minor additions were made to the 
MIMEOutputUtils

Possible Future Follow-Up Work:
    Buffering the SOAPPart XML is expensive if the xml document is large.  We 
should consider
    a streaming solution that avoids buffering.  This will require additional 
changes to MIMEOutputUtils.

I have a code change, which I will commit in a few minutes.


-- 
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]

Reply via email to