eclipse-ee4j / eclipse-ee4j/jersey
JsonBindingProvider does not use available genericType info when writing to outputstream
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
When trying to write a simple generic entity (Widget) to json I get the warning: Generic bound not found for type T declared in class Widget. I would expect that if I wrap the Widget in a GenericEntity> that the generic type information that is passed in to the MessageBodyWriter#writeTo method implemented in JsonBindingProvider would be passed on the the jsonb#toJson method as so: jsonb.writeTo(obj, genericType). That doesnt seem to be the case, as JsonBindingProvider ignores the generic type parameter altogether. Perhaps this is the intented behavior, but some clarification would be nice. I am also curious as to why these 2 lines were used:
`entityStream.write(jsonb.toJson(o).getBytes(AbstractMessageReaderWriterProvider.getCharset(mediaType)));
entityStream.flush();`
instead of using:
`jsonb.toJson(o, genericType, entityStream);`
Contributor guide
Assessment
This issue has not been assessed yet.