camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Balazs Szeti (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CAMEL-11622) Rest-dsl doesn't support post() endpoints with different request body types
Date Fri, 04 Aug 2017 04:37:00 GMT

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

Balazs Szeti edited comment on CAMEL-11622 at 8/4/17 4:36 AM:
--------------------------------------------------------------

After an investigation it turned out that the issue was fixed in 2.18.2 and is related to
[https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-10551]. So this is practically
a duplicate and can be closed.

I added a unit test for camel-spring-boot covering the case: having two POST endpoints unmarshalling
to different pojo types. It fails with 2.18.1, but passes with master.
https://github.com/apache/camel/pull/1868



was (Author: balazsszeti):
After an investigation it turned out that the issue was fixed in 2.18.2 and is related to
[https://issues.apache.org/jira/projects/CAMEL/issues/CAMEL-10551]
I added a unit test for camel-spring-boot covering the case: having two POST endpoints unmarshalling
to different pojo types. It fails with 2.18.1, but passes with master.
https://github.com/apache/camel/pull/1868


> Rest-dsl doesn't support post() endpoints with different request body types
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-11622
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11622
>             Project: Camel
>          Issue Type: Wish
>          Components: rest
>    Affects Versions: 2.18.1
>         Environment: Spring-Boot with Tomcat8 container
>            Reporter: Balazs Szeti
>
> The rest-dsl doesn't support two post() endpoints with different request body types.
> {code:java}
> restConfiguration()
>   .component("servlet")
>   .contextPath("/api")
>   .bindingMode(RestBindingMode.json)
> ;
> rest("/user")
>   .post("/employee").type(UserPojo.class)
>       .route()
>       .log("Name: ${body.name}")
>       .endRest()
> ;
> rest("/country")
>   .post("/origin").type(CountryPojo.class)
>       .route()
>       .log("Name: ${body.country}")
>       .endRest()
> ;
> {code}
> Both endpoints (/api/user/employee, /api/country/origin) tries to unmarshal the post
body to CountryPojo and a JsonProcessingException is thrown when a UserPojo json is sent to
/user/employee.
> The problem is that they share one JascksonDataFormat instance registered with name "json-jackson"
and the RestDefinition.type() sets the JascksonDataFormat.unmarshalType so at the end both
post() endpoints will try to unmarshal to the same class.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message