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

Michael Hewitt commented on HTTPCLIENT-1831:
--------------------------------------------

Thanks for the fast reply Oleg!

Sorry for the confusion I can give more information. I don't know the URI 
format that well so it could be that Camel is actually not compliant in their 
URIs and that they should change. Here are some example URIs that can not be 
built with the URI builder with the addition of this '/' prefix in the path 
normalization code. I am only using Camel and the URIBuilder to create Camel 
URIs for Kafka so that is the best example I have but I have included samples 
of other Camel component URIs that I think would also not be supported with the 
change to add a '/' to the path and therefore could not be built with the 
URIBuilder.

KAFKA
Here is my desired Camel URI = 
"kafka:TestTopic?brokers=localhost:9092&valueDeserializer=org.apache.kafka.common.serialization.ByteArraySerializer"

Snippet on how I am bulding the URI with URIBuilder
        URIBuilder uriBuilder = new URIBuilder()
                .setScheme("kafka")
                .setPath("TestTopic")
                .addParameter("brokers", "localhost:9092")
                .addParameter("valueDeserializer", 
"org.apache.kafka.common.serialization.ByteArraySerializer");

        uriBuilder.toString()

This outputs a string:
"kafka:/TestTopic?brokers=localhost%3A9092&valueDeserializer=org.apache.kafka.common.serialization.ByteArrayDeserializer"

Which when passed to Camel as the endpoint URI is interpreted by Camel as:
"kafka:///TestTopic?brokers=localhost%3A9092&valueDeserializer=org.apache.kafka.common.serialization.ByteArrayDeserializer

I got this Camel endpoint URI above from the Camel logs and Camel seems to add 
'//' to the URI internally.  But the extra '/' causes Camel to create a topic 
name "/TestTopic" in Kafka instead of what is desired which is "TestTopic"

Other Camel URI examples that should also break:

STOMP
"stomp:queue:destination?brokerURL=tcp://localhost:61613&login=test&passcode=test"

AMQP
"amqp:topic:notify?jmsMessageType=Text"

JMS
"jms:queue:order?messageConverter=#myMessageConverter"

Avro URI
"avro:http:localhost:9999?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol"
"avro:netty:localhost:9999/put?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol"

> Possible bug in URIBuilder
> --------------------------
>
>                 Key: HTTPCLIENT-1831
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1831
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 4.5.3
>            Reporter: Ivan Budincevic
>              Labels: bug
>             Fix For: 4.5.4, 4.6 Alpha1, 5.0 Alpha3
>
>
> While using the URIBuilder class to add a query parameter to a url using the  
> addParameter(String param, String value) method, the output of this method 
> would always append a "/" to the beginning of the url. 
> The problem was first noticed for urls that contained "./" at the beginning, 
> with the resulting url output from addParameter having "/./" at the 
> beginning, The attempted fix was to remove the "./" part of the urls in order 
> to have a relative http path, but using this method would still append a "/" 
> to the beginning, converting the url path to an absolute path instead of the 
> original relative path. 
> This problem did not occur with versions previous to 4.5.3 



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to