cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yan Min Sheng (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-4772) AssessmentDataStore do not cache the last attachment binary stream, so the DataHandler.writeTo() will fail if it is called for the second time
Date Wed, 23 Jan 2013 04:52:12 GMT

    [ https://issues.apache.org/jira/browse/CXF-4772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13559614#comment-13559614
] 

Yan Min Sheng edited comment on CXF-4772 at 1/23/13 4:51 AM:
-------------------------------------------------------------

Well, the problem here is after call DataHandler.writeTo first in application,
img.writeTo(fos); //DelegatingStream to handle this, it will get the binary content
imgout.getImage().add(img);
fos.close();// it will close the DelegatingStream, i.e, the MimeBodyPartInputStream will be
closed.

After that, when the server side return the ImageDepot to client, the AttachmentOutInterceptor
will be called, and AttachmentDataStore.getInputStream() will return the same DelegatingInputStream.
Here,  the problem is the MimeBodyPartInputStream can not handle the read request.
Daemon Thread [Default Executor-thread-5] (Suspended)	
	AttachmentDataSource.getInputStream() line: 83	
	LazyDataSource.getInputStream() line: 90	
	DataHandler.writeTo(OutputStream) line: 302	
	AttachmentSerializer.writeAttachments() line: 265	
	AttachmentOutInterceptor$AttachmentOutEndingInterceptor.handleMessage(Message) line: 103

	PhaseInterceptorChain.doIntercept(Message) line: 262	
	OutgoingChainInterceptor.handleMessage(Message) line: 77	
	PhaseInterceptorChain.doIntercept(Message) line: 262	
	ChainInitiationObserver.onMessage(Message) line: 121	

                
      was (Author: shengym):
    Well, the problem here is after call DataHandler.writeTo first in application,
img.writeTo(fos); //DelegatingStream to handle this, it will get the binary content
imgout.getImage().add(img);
fos.close();// it will close the DelegatingStream, i.e, the MimeBodyPartInputStream will be
closed.

After that, when the server side return the ImageDepot to client, the AttachmentOutInterceptor
will be called, and AttachmentDataStore.getInputStream() will return the same DelegatingInputStream.
Here,  the problem is the MimeBodyPartInputStream can not handle the read request.
Daemon Thread [Default Executor-thread-5] (Suspended)	
	AttachmentDataSource.getInputStream() line: 83	
	LazyDataSource.getInputStream() line: 90	
	DataHandler.writeTo(OutputStream) line: 302	
	AttachmentSerializer.writeAttachments() line: 265	
	AttachmentOutInterceptor$AttachmentOutEndingInterceptor.handleMessage(Message) line: 103

	PhaseInterceptorChain.doIntercept(Message) line: 262	
	OutgoingChainInterceptor.handleMessage(Message) line: 77	
	PhaseInterceptorChain.doIntercept(Message) line: 262	
	ChainInitiationObserver.onMessage(Message) line: 121	
	ServletDestination(AbstractHTTPDestination).invoke(ServletConfig, ServletContext, HttpServletRequest,
HttpServletResponse) line: 211	
	POJOJaxWsWebEndpoint.invoke(HttpServletRequest, HttpServletResponse) line: 114	
	LibertyJaxWsServlet.handleRequest(HttpServletRequest, HttpServletResponse) line: 121	
	LibertyJaxWsServlet.doPost(HttpServletRequest, HttpServletResponse) line: 80	
	LibertyJaxWsServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 595

	LibertyJaxWsServlet.service(ServletRequest, ServletResponse) line: 72	
	ServletWrapper(ServletWrapper).service(ServletRequest, ServletResponse, WebAppServletInvocationEvent)
line: 1235	
	ServletWrapper(ServletWrapper).handleRequest(ServletRequest, ServletResponse, WebAppDispatcherContext)
line: 758	
	ServletWrapper(ServletWrapper).handleRequest(ServletRequest, ServletResponse) line: 441	
	WebAppFilterManagerImpl(WebAppFilterManager).invokeFilters(ServletRequest, ServletResponse,
IServletContext, RequestProcessor, EnumSet<CollaboratorInvocationEnum>) line: 1041	
	CacheServletWrapper.handleRequest(ServletRequest, ServletResponse) line: 78	
	WebContainer(WebContainer).handleRequest(IRequest, IResponse, VirtualHost, RequestProcessor)
line: 867	
	DynamicVirtualHost$2.run() line: 260	
	HttpDispatcherLink$TaskWrapper.run() line: 531	
	Worker.executeWork(Runnable) line: 439	
	Worker.run() line: 421	
	Thread.run() line: 736	

                  
> AssessmentDataStore do not cache the last attachment binary stream, so the DataHandler.writeTo()
will fail if it is called for the second time
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-4772
>                 URL: https://issues.apache.org/jira/browse/CXF-4772
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.6.2
>            Reporter: Yan Min Sheng
>            Priority: Critical
>              Labels: patch
>         Attachments: CXF4772.patch
>
>
> When trying test MTOM through JAX-WS, we found that the AssessmentDataStore can only
be written once. It will fail for the second time. After investigation, it seems that the
binary stream is not cached by the AssessmentDataStore, so each time a DelegatingStream will
be created to handle the writeTo request. While the DelegatingStream is closed, it can not
handle the writeTo request again.
> The suggestion is to cache the newly created attachement after it is created in AttachmentDeserializer
> The interface is:
> /**
>  * This class was generated by the JAXWS SI.
>  * JAX-WS RI 2.0_01-b15-fcs
>  * Generated source version: 2.0
>  * 
>  */
> @WebService(name = "MTOMInterface", targetNamespace = "http://shengym.com/wssvt/acme/InsBusiness/")
> public interface MTOMInterface {
>     /**
>      * 
>      * @param input
>      * @param params
>      * @return
>      *     returns com.ibm.wssvt.acme.insbusiness.ImageDepot
>      * @throws InsFaultException
>      */
>     @WebMethod(action = "http://shengym.com/wssvt/acme/sendImage")
>     @WebResult(name = "output", targetNamespace = "")
>     @RequestWrapper(localName = "sendImage", targetNamespace = "http://shengym.com/wssvt/acme/InsBusiness/",
className = "com.shengym.wssvt.acme.insbusiness.SendImage")
>     @ResponseWrapper(localName = "sendImageResponse", targetNamespace = "http://shengym.com/wssvt/acme/InsBusiness/",
className = "com.shengym.wssvt.acme.insbusiness.SendImageResponse")
>     public ImageDepot sendImage(
>         @WebParam(name = "input", targetNamespace = "")
>         ImageDepot input,
>         @WebParam(name = "params", targetNamespace = "")
>         ParamsType params)
>         throws InsFaultException
>     ;
> }
> ImageDepot.java
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "ImageDepot", propOrder = {
>     "image"
> })
> public class ImageDepot {
>     @XmlElement(required = true)
>     @XmlMimeType("multipart/*")
>     protected List<DataHandler> image;
>     /**
>      * Gets the value of the image property.
>      * 
>      * <p>
>      * This accessor method returns a reference to the live list,
>      * not a snapshot. Therefore any modification you make to the
>      * returned list will be present inside the JAXB object.
>      * This is why there is not a <CODE>set</CODE> method for the image property.
>      * 
>      * <p>
>      * For example, to add a new item, do as follows:
>      * <pre>
>      *    getImage().add(newItem);
>      * </pre>
>      * 
>      * 
>      * <p>
>      * Objects of the following type(s) are allowed in the list
>      * {@link DataHandler }
>      * 
>      * 
>      */
>     public List<DataHandler> getImage() {
>         if (image == null) {
>             image = new ArrayList<DataHandler>();
>         }
>         return this.image;
>     }
> }
> The client code will look like:
> 	 void setOutputImage(ImageDepot imgin, ImageDepot imgout) throws Exception {
> 		List<DataHandler> imglist = imgin.getImage();
> 		try {
> 			DataHandler img = null;
> 			// traverse each of the image
> 			for (DataHandler img : imglist) {
> 				if (img != null) {
> 					File f = new File(msgID + "_server_image"+ imglist.indexOf(img));
> 					if (f.exists()) {
> 						f.delete();
> 					}
> 					FileOutputStream fos = new FileOutputStream(f);
> 					img.writeTo(fos);
> 					imgout.getImage().add(img);
> 					fos.close();
> 				} 
> 			}			
> 		} catch (Exception e) {
> 			System.out.println("Exception caught in MTOMService sendImage ...");
> 			e.printStackTrace(System.out);
> 			throw e;
> 		}
> 	}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message