Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] Request for clarification [Response.fromResponse()]


Hey Ron,

sorry for my delayed response. This mail was on my TODO list far too long. 

I must confess that I didn't read all the comments in the RESTEasy issue you mentioned, but I would like to bring up my thoughts regarding one assumption you made:
  

Consider

Response.ok(new GenericEntity<List<Bean>>(Arrays.<Bean>asList(new Bean("a"), new Bean("b"))) {}).build();

It is clear from the Response.ok() javadoc that the "actual entity" is a List<> and not a GenericEntity<>.  Presumably, then, Response.getEntity(), which, according to the javadoc, returns "the message entity Java instance", should return the List<>.

I don't think this is true. IMO there is nothing in the API docs that forces an implementation to "unpack" the actual entity wrapped by GenericEntity. The API docs of ok() just state:
 
    It is the callers responsibility to wrap the actual entity with GenericEntity if preservation of its generic type is required. 

I just had a quick look at the Jersey implementation of ResponseBuilder.entity(Object) and Jersey doesn't seem to perform any unpacking of GenericEntity here.

So IMO Response.getEntity() should return the original GenericEntity which also allows the caller to get all the generic type information.

Any other thoughts?

Christian

 
--

Back to the top