smallrye-reactive-messaging
smallrye-reactive-messaging copied to clipboard
Bootstrap servers parsing fails
Description
When providing a kafka.bootstrap.servers property wrapped in quotation marks, parsing fails with an error message stating the bootstrap server is invalid. I'm very aware that this is a small quality of life change, but it would be great that either way, you do not encounter this issue.
Environment
Java:
> java -version
openjdk version "19-ea" 2022-09-20
OpenJDK Runtime Environment (build 19-ea+28-2110)
OpenJDK 64-Bit Server VM (build 19-ea+28-2110, mixed mode, sharing)
Quarkus BOM: 2.10.3.Final
Example
kafka.bootstrap.servers="joran-tes-cbbd-tuej----kjigoug.bf2.kafka.rhcloud.com:443"
Fails with parsing.
kafka.bootstrap.servers=joran-tes-cbbd-tuej----kjigoug.bf2.kafka.rhcloud.com:443
Parses correctly.
I suppose we could remove the first and last ". @ozangunalp WDYT?
I wonder if smallrye config provides an interceptor for stripping " from values.
ah yes, @radcortez ?
What is the failure exactly? Is it the parsing at the Kafka config layer?
The issue is that we cannot arbitrarily remove quotations from configuration values because we don't know if the user intended them to be there or not. It is possible to write an interceptor to do such operations to specific keys, but it would need to be registered on the consumer side (in this case, RM).
Do you want me to add one?
Failure isn't a big deal, in all honesty. It just causes some confusion, as the bootstrap URL is correct. However, the quotation marks indeed interfere with the class org.apache.kafka.clients.ClientUtils, so it's the Kafka layer. I'd probably expect us to sanitise the string before passing it to the Kafka layer. It would improve developer experience a small bit, in my view.
The bootstrap servers should not be wrapped in quotes (Kafka rejects it). I believe we should sanitize on our side as the "key" of the bootstrap server can be the global one, the channel one, or the connector one. The channel one is unknown for MP Config.
Isn't this the case for every config property? For exemple if you pass value.serializer="org.apache.kafka.common.serialization.StringSerializer" config you'd get a ClassNotFoundException.
An alternative could be to use a @ConfigMapping interface and add specific converters to each property.
We cannot add specific converters, the set of properties is open.
Closing - unfortunately, not easy solution - except make sure to not wrap the values with "