-
Bug
-
Resolution: Done
-
Major
-
2.0.1.GA
-
None
-
None
Given this resource method:
@Path("/resource")
public SomeResource {
@GET
List<MyType> getStuff()
}
A custom implementation of MessageBodyWriter is passed "null" for its genericType argument (which should contain List<MyType>). This prevents my implementation to detect the type in the collection.
The negotiation is based on the client setting an Accept header that matches a @Produces on my MessageBodyWriter. The isWriteable() method is called, but my implementation returns false due to the missing genericType argument.
The problem is located in ResourceMethod line 392:
Type type = null;
the "type" variable is assigned null when in fact it could default to the method signature's generic type, which is available in "this.genericReturnType":
Type type = this.genericReturnType;
If the entity is a GenericEntity, the value for "type" will later be overridden by what the resource provided.
Workaround is to add a @Produces annotation to the resource that matches the Accept header. I don't want to do this since the value returned by the resource can be encoded into multiple mime-types by different writers. Adding a new encoding would require that I modify all my resources.