cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <>
Subject Re: two issues in org.apache.cxf.jaxrs.provider.DataSourceProvider
Date Tue, 01 Jul 2014 01:38:21 GMT

On Jun 30, 2014, at 9:07 PM, iris ding <> 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 
> 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 -
Talend Community Coder -

View raw message