Pasquale Congiusti created CAMEL-17520:
------------------------------------------
Summary: Cannot use square brackets in HTTP parameters
Key: CAMEL-17520
URL: https://issues.apache.org/jira/browse/CAMEL-17520
Project: Camel
Issue Type: Bug
Affects Versions: 3.12.0
Reporter: Pasquale Congiusti
It was reported on mailing list, there is some problem when trying to use
square brackets as part of the URI params. I've run some expertiment with the
RAW() function, but this is only applied to the value parameter, not the
variable name (ie, _param=RAW(value)_).
As a reproducer, we may run this route (ie, via Camel K):
{code}
// camel-k: language=java
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestParamType;
import org.apache.camel.Exchange;
public class Test extends RouteBuilder {
@Override
public void configure() throws Exception {
rest()
.get("/hello")
.param().name("test[bogus]").type(RestParamType.query).defaultValue("false").description("Just
for testing").endParam()
.to("direct:hello");
from("direct:hello")
.setHeader(Exchange.CONTENT_TYPE, constant("text/plain"))
.setBody().simple("${headers.test[bogus]}");
// Write your routes here, for example:
from("timer:java?period=3000")
.to("http://localhost:8080/hello?test[bogus]=true")
.log("${body}");
}
}
{code}
It will end up with error:
{code}
[1] Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint: http://localhost:8080/hello?test%5Bbogus%5D=true due to:
Error binding property (test[bogus]=true) with name: test[bogus] on bean:
http://localhost:8080/hello?test%5Bbogus%5D=true with value: true
[1] at
org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:963)
[1] at
org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:845)
[1] at
org.apache.camel.support.CamelContextHelper.resolveEndpoint(CamelContextHelper.java:123)
[1] at
org.apache.camel.reifier.SendReifier.resolveEndpoint(SendReifier.java:43)
[1] at
org.apache.camel.reifier.SendReifier.createProcessor(SendReifier.java:36)
[1] at
org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:838)
[1] at
org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579)
[1] at
org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236)
[1] ... 31 more
[1] Caused by: org.apache.camel.PropertyBindingException: Error binding
property (test[bogus]=true) with name: test[bogus] on bean:
http://localhost:8080/hello?test%5Bbogus%5D=true with value: true
[1] at
org.apache.camel.support.PropertyBindingSupport.doSetPropertyValue(PropertyBindingSupport.java:476)
[1] at
org.apache.camel.support.PropertyBindingSupport.doBuildPropertyOgnlPath(PropertyBindingSupport.java:326)
[1] at
org.apache.camel.support.PropertyBindingSupport.doBindProperties(PropertyBindingSupport.java:210)
[1] at
org.apache.camel.support.PropertyBindingSupport.access$100(PropertyBindingSupport.java:88)
[1] at
org.apache.camel.support.PropertyBindingSupport$Builder.bind(PropertyBindingSupport.java:1789)
[1] at
org.apache.camel.support.DefaultEndpoint.setProperties(DefaultEndpoint.java:413)
[1] at
org.apache.camel.support.DefaultEndpoint.configureProperties(DefaultEndpoint.java:388)
[1] at
org.apache.camel.support.DefaultComponent.setProperties(DefaultComponent.java:425)
[1] at
org.apache.camel.component.http.HttpComponent.createEndpoint(HttpComponent.java:377)
[1] at
org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:171)
[1] at
org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:929)
[1] ... 38 more
[1] Caused by: java.lang.IllegalArgumentException: Cannot set property:
test[bogus] as a Map because target bean has no setter method for the Map
[1] at
org.apache.camel.support.PropertyBindingSupport.setPropertyCollectionViaReflection(PropertyBindingSupport.java:523)
[1] at
org.apache.camel.support.PropertyBindingSupport.doSetPropertyValue(PropertyBindingSupport.java:453)
[1] ... 48 more
{code}
Trying to apply the RAW() function on the parameter (ie,
?RAW(test[bogus])=true) does not convert the parameter, but create a new one
called _RAW(test[bogus])_
--
This message was sent by Atlassian Jira
(v8.20.1#820001)