[
https://issues.apache.org/jira/browse/CAMEL-12097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16309531#comment-16309531
]
ASF GitHub Bot commented on CAMEL-12097:
----------------------------------------
onders86 closed pull request #2158: CAMEL-12097- handle if both path and query
params set and supress wit…
URL: https://github.com/apache/camel/pull/2158
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
index 47c02936131..b4c3b2549bf 100644
---
a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
+++
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
@@ -211,10 +211,6 @@ private static String buildUri(RestletEndpoint endpoint,
Exchange exchange) thro
if (uri == null) {
uri = endpoint.getProtocol() + "://" + endpoint.getHost() + ":" +
endpoint.getPort() + endpoint.getUriPattern();
}
- // include any query parameters if needed
- if (endpoint.getQueryParameters() != null) {
- uri = URISupport.appendParametersToURI(uri,
endpoint.getQueryParameters());
- }
// substitute { } placeholders in uri and use mandatory headers
LOG.trace("Substituting '{value}' placeholders in uri: {}", uri);
@@ -235,6 +231,11 @@ private static String buildUri(RestletEndpoint endpoint,
Exchange exchange) thro
// we replaced uri so reset and go again
matcher.reset(uri);
}
+
+ // include any query parameters if needed
+ if (endpoint.getQueryParameters() != null) {
+ uri = URISupport.appendParametersToURI(uri,
endpoint.getQueryParameters());
+ }
// rest producer may provide an override query string to be used which
we should discard if using (hence the remove)
String query = (String)
exchange.getIn().removeHeader(Exchange.REST_HTTP_QUERY);
diff --git
a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
index 34ccd059ad2..f2e68282831 100644
---
a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
+++
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTest.java
@@ -32,6 +32,12 @@ public void testRestletProducerGet() throws Exception {
assertEquals("123;Donald Duck", out);
}
+ @Test
+ public void testRestletProducerGetWithPathQueryParams() throws Exception {
+ String out =
template.requestBodyAndHeader("direct:startWithPathQueryParams", null, "id",
123, String.class);
+ assertEquals("1235;Donald Duck", out);
+ }
+
@Test
public void testRestletProducerDelete() throws Exception {
String out = template.requestBodyAndHeader("direct:delete", null,
"id", 123, String.class);
@@ -45,6 +51,8 @@ protected RouteBuilder createRouteBuilder() throws Exception {
public void configure() throws Exception {
from("direct:start").to("restlet:http://localhost:" + portNum
+ "/users/{id}/basic").to("log:reply");
+
from("direct:startWithPathQueryParams").to("restlet:http://localhost:" +
portNum + "/users/{id}/basic?id=1235").to("log:reply");
+
from("direct:delete").to("restlet:http://localhost:" + portNum
+ "/users/{id}/basic?restletMethod=DELETE");
from("restlet:http://localhost:" + portNum +
"/users/{id}/basic?restletMethods=GET,DELETE")
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Combination of path param and query param does not work
> -------------------------------------------------------
>
> Key: CAMEL-12097
> URL: https://issues.apache.org/jira/browse/CAMEL-12097
> Project: Camel
> Issue Type: Bug
> Components: camel-restlet
> Affects Versions: 2.20.1
> Reporter: Radek Mensik
> Assignee: Önder Sezgin
> Fix For: 2.20.2, 2.21.0
>
>
> If in route are used both path parameter and query parameter:
> {code:java}
> restlet:{{data.access.url}}/v2/users/{userId}?projection=full
> {code}
> then because of commit :
> https://github.com/apache/camel/commit/4da8d0ad4472e69a5728f67fa121b3b4150fdc33#diff-470ee30498bbf9ea5b6ea223650c0e1c
> on lines 216-219 are escaped "{" "}" so userId in my example is never
> replaced.
> Escaping is done in URISupport.appendParametersToURI on line:
> {code:java}
> URI uri = new URI(normalizeUri(originalURI));
> {code}
> There is workaround to use Exchange.HTTP_QUERY header for query parameter and
> path must not contain query parameters.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)