You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@juneau.apache.org by "James Bognar (JIRA)" <ji...@apache.org> on 2019/08/18 18:41:00 UTC
[jira] [Created] (JUNEAU-131) REST annotations need type()
annotation.
James Bognar created JUNEAU-131:
-----------------------------------
Summary: REST annotations need type() annotation.
Key: JUNEAU-131
URL: https://issues.apache.org/jira/browse/JUNEAU-131
Project: Juneau
Issue Type: Task
Components: Code
Affects Versions: 8.1.0
Reporter: James Bognar
Because Spring uses CGLIB which recompiles classes at runtime (ugh), and since CGLIB was written before Java annotations were around and is an unsupported library (ugh #2), if you expose the following REST method as a Spring bean, the generics information in the following information get stripped and we can no longer determine that we should parse a list of beans:
{{}}{{@RestMethod}}
{{public void postFoo(@Body List<MyBean> beans) \{...}}}
The behavior is that we'll end up creating a list of ObjectMaps which will almost always result in a ClassCastException when you try to interact with the list.
To help alleviate this issue, we can introduce an annotation to explicitly specify the parsed type:
{{@RestMethod}}
{{public void postFoo(@Body(type=\{List.class,MyBean.class}) List<MyBean> beans) \{...}}}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)