Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarkus adapter startup fails with Kafka config property having empty string value #2941

Closed
calohmn opened this issue Nov 11, 2021 · 5 comments · Fixed by #2944
Closed

Quarkus adapter startup fails with Kafka config property having empty string value #2941

calohmn opened this issue Nov 11, 2021 · 5 comments · Fixed by #2944
Assignees
Labels
Milestone

Comments

@calohmn
Copy link
Contributor

calohmn commented Nov 11, 2021

Trying to deploy a Quarkus-based protocol adapter built using current master, startup fails with this exception:

ERROR: Failed to start application (with profile prod)
java.util.NoSuchElementException: SRCFG00040: The config property hono.kafka.commonClientConfig."ssl.endpoint.identification.algorithm" is defined as the empty String ("") which the following Converter considered to be null: io.smallrye.config.Converters$BuiltInConverter
at io.smallrye.config.SmallRyeConfig.convertValue(SmallRyeConfig.java:284)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:239)
at io.smallrye.config.ConfigMappingProvider.lambda$processLazyMap$0(ConfigMappingProvider.java:540)
at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:844)

The issue can be reproduced with the QuarkusPropertyBindingTest unit test (in the adapter-base-quarkus module) by adding a property with an empty string value in adapter-base-quarkus/src/test/resources/application.yaml.

@calohmn calohmn added the bug label Nov 11, 2021
@calohmn calohmn added this to the 1.11.0 milestone Nov 11, 2021
@calohmn
Copy link
Contributor Author

calohmn commented Nov 11, 2021

I thought, using Map<String, Optional<String>> as return values in the KafkaClientOptions methods would help here, but that causes a ClassCastException. I also had no luck with a custom converter. @sophokles73 Any idea here?

@sophokles73
Copy link
Contributor

I do not really understand what you are trying to achieve and what problem you are experiencing. Can you be a little more elaborate?

@calohmn
Copy link
Contributor Author

calohmn commented Nov 11, 2021

When using the IoT Packages Hono helm chart with Kafka parameters, the Kafka config contains this by default:

      kafka:
        commonClientConfig:
          ssl.endpoint.identification.algorithm: ""

When installing the Helm chart, using Kafka and using the Hono quarkus images from current master, the adapter startup fails with the above exception.
The same kind of error comes when running QuarkusPropertyBindingTest in the adapter-base-quarkus module, having added a field with an empty string value in adapter-base-quarkus/src/test/resources/application.yaml, like this:

[...]
  kafka:
    commonClientConfig:
      empty: ""
[...]

So, the question is how to make it possible that the Maps returned by the KafkaClientOptions class can contain empty-string values.

@sophokles73
Copy link
Contributor

sophokles73 commented Nov 11, 2021

Well, we could also simply prevent the empty string being used as the property value, couldn't we? Have you checked if it works if you simply omit the ""?

@calohmn calohmn changed the title Adapter startup fails with Kafka config property having empty string value Quarkus adapter startup fails with Kafka config property having empty string value Nov 12, 2021
calohmn added a commit to bosch-io/hono that referenced this issue Nov 12, 2021
@calohmn
Copy link
Contributor Author

calohmn commented Nov 12, 2021

When omitting the "", there won't be the NoSuchElementException, but then the map entry value will be null.
And this has different semantics and will also cause the adapter startup to fail.
The intention is here to explicitly set the "ssl.endpoint.identification.algorithm" property value to the empty string in order to override the default value (https). It looks like a null value would let the default value be used.

There are long discussions on the handling of empty string values in SmallRye/Eclipse MicroProfile Config - see microprofile/microprofile-config#671. Unfortunately, there currently doesn't seem to be a straightforward way to differentiate between a String with a null value and an empty String.

I've created #2944 now to apply the solution mentioned in microprofile/microprofile-config#671 - using the ConfigValue API.

@calohmn calohmn self-assigned this Nov 12, 2021
calohmn added a commit that referenced this issue Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants