Hi
On 01/07/14 07:19, iris ding wrote:
Thanks Daniel for digging out the issue.

So how about below change to convert the ClassCastException to a 415
response?

     public T readFrom(Class<T> cls, Type genericType, Annotation[]
annotations,
                                MediaType type,
                                MultivaluedMap<String, String> headers,
InputStream is)
         throws IOException,WebApplicationException {
         DataSource ds = new InputStreamDataSource(is, type.toString());
         try{
         return cls.cast(DataSource.class.isAssignableFrom(cls) ? ds : new
DataHandler(ds));
         }
         catch (ClassCastException e)
         {
                
                WebApplicationException ee= new
WebApplicationException(e,Response.status(415).build());
                throw ee;
                
         }
     }

I'll have a look into fixing the cast exception


I also have a question here, you mentioned we can implement our own
provider, How can we replace the CXF built in DataSourceProvider with our
own?

you'd just register it in jaxrs:providers. The auto-discovery is also possible, for Spring only endpoints for now.

Cheers, Sergey


--
View this message in context: 
http://cxf.547215.n5.nabble.com/two-issues-in-org-apache-cxf-jaxrs-provider-DataSourceProvider-tp5745783p5745792.html
Sent from the cxf-dev mailing list archive at Nabble.com.


Reply via email to