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 2022/06/24 19:21:00 UTC
[jira] [Closed] (JUNEAU-131) REST annotations need type() annotation.
[ https://issues.apache.org/jira/browse/JUNEAU-131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James Bognar closed JUNEAU-131.
-------------------------------
Resolution: Fixed
Implemented in 9.0.0
> 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
> Priority: Major
>
> 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
(v8.20.7#820007)