On Jun 30, 2014, at 9:07 PM, iris ding <irisdin...@gmail.com> wrote:
> Hi Guys, > > I think There are two issues in > org.apache.cxf.jaxrs.provider.DataSourceProvider: > Issue 1: ClassCastException if you post a FileDataSource in your resource > class: > Issue 2: Return the original InputStream directly in > InputStreamDataSource.getInputStream(). > > > I have created a JIRA in > https://issues.apache.org/jira/browse/CXF-5835 and put more details there. > > Would you take a look at the problem and see whether we can make any > modification for it? > The second one is NOT a bug and should not be fixed. That’s a bug in your code. The javadoc for “available()” specifically says: "Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream." CXF tries hard to stream everything (including attachments). Thus, the “available()” method likely will only return the number of bytes that have been received so far by the server which could be MUCH less than the full length of the attachment. -- Daniel Kulp dk...@apache.org - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com