[
https://issues.apache.org/jira/browse/CAMEL-22754?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-22754:
--------------------------------
Priority: Minor (was: Major)
> Additional route step after a body is set to Response may alter the HTTP code
> in the Response
> ---------------------------------------------------------------------------------------------
>
> Key: CAMEL-22754
> URL: https://issues.apache.org/jira/browse/CAMEL-22754
> Project: Camel
> Issue Type: Bug
> Components: came-core, came-cxf
> Affects Versions: 4.14.2
> Reporter: John Yin
> Priority: Minor
> Attachments: camel-cxf-rest-groovy-example.zip
>
>
> When a CXF consumer route constructs a jakarta.ws.rs.core.Response with a
> status code (e.g. 202), any additional Camel route step afterward can alter
> the status code actually returned. In the example below:
> {quote}from("cxfrs:bean:rsServerTest?bindingStyle=SimpleConsumer")
> .process({
> Response resp
> it.in.setBody('\{"response":"got it"}')
> Response.ResponseBuilder jaxrsResponseBuilder =
> Response.status(202).entity(it.in.getBody(String.class))
> jaxrsResponseBuilder.type('application/json')
> it.in.setBody(jaxrsResponseBuilder.build()) // body contains
> ResponseImpl\{status=202} now
> })
> // any additional step here will cause the response code 202 to become 200.
> .log("this step causes[^camel-cxf-rest-groovy-example.zip] the response code
> 202 to become 200 in Camel 4.14.2."){quote}
> An example to reproduce the issue is attached. In the example, you can see
> the HTTP code returned is 200 instead of 202.
>
> If the .log is removed from the route, it would return HTTP 202 using Camel
> 4.14.2.
>
> If the Camel 4.14.1 is used, then the above route works, HTTP 202 is
> returned.
>
> To overcome this issue, one would need to remove any route step after the
> body is set to the Response, or explicitly set the CamelHttpResponseCode
> header.
>
> Thanks in advance for investigating this issue.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)