You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Frank Denninger (Jira)" <ji...@apache.org> on 2020/08/05 21:18:00 UTC
[jira] [Comment Edited] (CAMEL-15370) CxfRsProducer: All but last
value of query parameter with multiple values are lost
[ https://issues.apache.org/jira/browse/CAMEL-15370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17171756#comment-17171756 ]
Frank Denninger edited comment on CAMEL-15370 at 8/5/20, 9:17 PM:
------------------------------------------------------------------
Hi Chandrakant, this implementation will cause problems if the value contains an & (or %26 escaped)
See this failing testcase:
{code:java}
@Test
public void testProducerWithQueryParametersWithMultipleValues2() {
Exchange exchange = template.send("cxfrs://http://localhost:" + getPort2() + "/" + getClass().getSimpleName() + "/testQuery?httpClientAPI=true&synchronous=true", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message inMessage = exchange.getIn();
// set the Http method
inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, InputStream.class);
inMessage.setHeader(Exchange.HTTP_QUERY, "id=1%262");
inMessage.setBody(null);
}
});
// get the response message
String response = exchange.getOut().getBody(String.class);
assertNotNull(response, "The response should not be null");
assertEquals("id=1%262", response, "The response value is wrong");
}
{code}
You also cause an npe if the value is null in the map.
I dont't really see a valid implemenation that leverages a csv syntax in the values of the Map, that doesn't cause incompatiblity issues for users that provide the Map with CxfConstatns.CAMEL_CXF_RS_QUERY_MAP.
was (Author: k5):
Hi Chandrakant, this implementation will cause problems if the value contains an & (or %26 escaped)
See this failing testcase:
{code:java}
@Test
public void testProducerWithQueryParametersWithMultipleValues2() {
Exchange exchange = template.send("cxfrs://http://localhost:" + getPort2() + "/" + getClass().getSimpleName() + "/testQuery?httpClientAPI=true&synchronous=true", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message inMessage = exchange.getIn();
// set the Http method
inMessage.setHeader(Exchange.HTTP_METHOD, "GET");
inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, InputStream.class);
inMessage.setHeader(Exchange.HTTP_QUERY, "id=1%262");
inMessage.setBody(null);
}
});
// get the response message
String response = exchange.getOut().getBody(String.class);
assertNotNull(response, "The response should not be null");
assertEquals("id=1%262", response, "The response value is wrong");
}
{code}
You also cause an npe if the value is null in the map
> CxfRsProducer: All but last value of query parameter with multiple values are lost
> ----------------------------------------------------------------------------------
>
> Key: CAMEL-15370
> URL: https://issues.apache.org/jira/browse/CAMEL-15370
> Project: Camel
> Issue Type: Bug
> Components: came-cxf
> Affects Versions: 3.3.0
> Reporter: Frank Denninger
> Assignee: Freeman Yue Fang
> Priority: Major
> Fix For: 3.5.0
>
> Attachments: CAMEL-15370.patch, CAMEL-15370_Chandra.patch
>
>
> If using a query parameter name multiple times, only the last value is actually used.
>
> e.g. .to("cxfrs:[http://example.com/]") with Exchange value Exchange.HTTP_QUERY id=1&id=2 will call to example.com with id=2
>
> As far as i can tell the problem is caused by CxfRsProducer::getQueryParametersFromQueryString. In the method all query paramters are inserted in a map, and only the last use of a parameter name is preserved.
>
> One solution would be to insert the values directy into the client field, skipping the Map.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)