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 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?
--
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.