cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-6870) CXF doesn't check the message body's generic type
Date Mon, 18 Apr 2016 09:53:25 GMT

    [ https://issues.apache.org/jira/browse/CXF-6870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15245387#comment-15245387
] 

Sergey Beryozkin commented on CXF-6870:
---------------------------------------

Thanks. By the way, I'm not sure, based on one of the tests how much checking RI does in this
case.
Such signatures can be tricky to deal with, example, where is the limit, say we have List
of Strings and List of Map of Integer to Strings, so writing the code which can cleanly separate
the providers is not easy (can be quite messy I guess). 

The workaround always exists as you demonstrated (checking Type in isReadable/isWriteable).
But I agree this issue needs to be investigated. 

> CXF doesn't check the message body's generic type
> -------------------------------------------------
>
>                 Key: CXF-6870
>                 URL: https://issues.apache.org/jira/browse/CXF-6870
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.1.3, 3.1.6, 3.0.9
>         Environment: mac, windows
>            Reporter: Neal Hu
>             Fix For: 3.0.10, 3.1.7, 3.2.0
>
>         Attachments: ListAProvider.java, ListBProvider.java, Resource.java, beans.xml
>
>
> CXF doesn't check the message body's generic type, please see the sample below.
> {code:java}
> public class ListAProvider implements MessageBodyWriter<List<String>> 
> public class ListBProvider implements MessageBodyWriter<List<Integer>> 
> resource class:
> 	@GET
> 	@Path("/echo/{param}")
> 	@Produces("application/json")
> 	public List<String> echo(@PathParam("param")String name){
> 		List<String> list = new ArrayList<String>();
> 		list.add("hello");
> 		list.add(name);
> 		return list;
> 	}
> 	
> 	@GET
> 	@Path("/echo2/{param}")
> 	@Produces("application/json")
> 	public List<Integer> echo2(@PathParam("param")String name){
> 		List<Integer> list = new ArrayList<Integer>();
> 		list.add(1);
> 		list.add(2);
> 		return list;
> 	}
> {code}
> No matter you request echo or echo2 resource method, the selected provider is ListBProvider



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message