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

4.x: MpConfigSources.create does not handle empty values #9506

Open
romain-grecourt opened this issue Nov 19, 2024 · 0 comments
Open

4.x: MpConfigSources.create does not handle empty values #9506

romain-grecourt opened this issue Nov 19, 2024 · 0 comments
Assignees
Labels
4.x Version 4.x bug Something isn't working config messaging Reactive Messaging microprofile P2
Milestone

Comments

@romain-grecourt
Copy link
Contributor

Environment Details

  • Helidon Version: 4.1.4
  • Helidon MP

Problem Description

io.helidon.config.mp.MpConfigSources.create does not handle empty values (I.e. ""), which then results in java.util.NoSuchElementException because the MicroProfile config specification does not support empty values.


The following code detaches SE config as a map

configuration.putAll(configToPut.detach().asMap().orElse(Map.of()));

And then builds a MicroProfile Config from the map:

This makes it impossible to supply the following configuration:

mp.messaging:
  connector:
      helidon-kafka:
        ssl.endpoint.identification.algorithm: ${EMPTY}
Exception in thread "main" java.util.NoSuchElementException: Property "ssl.endpoint.identification.algorithm" is not available in configuration
	at io.helidon.config.mp.MpConfigImpl.lambda$getValue$2(MpConfigImpl.java:127)
	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
	at io.helidon.config.mp.MpConfigImpl.getValue(MpConfigImpl.java:127)
	at io.helidon.config.mp.SeConfig.asMap(SeConfig.java:262)
	at io.helidon.messaging.connectors.kafka.KafkaConfig.create(KafkaConfig.java:63)
	at io.helidon.messaging.connectors.kafka.KafkaPublisher$Builder.config(KafkaPublisher.java:373)
	at io.helidon.messaging.connectors.kafka.KafkaConnector.getPublisherBuilder(KafkaConnector.java:197)
	at io.helidon.messaging.connectors.kafka.KafkaConnector$Proxy$_$$_WeldClientProxy.getPublisherBuilder(Unknown Source)
	at io.helidon.microprofile.messaging.OutgoingConnector.lambda$getPublisher$0(OutgoingConnector.java:74)
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)
	at io.helidon.microprofile.messaging.OutgoingConnector.getPublisher(OutgoingConnector.java:73)
	at io.helidon.microprofile.messaging.UniversalChannel.connect(UniversalChannel.java:130)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1787)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at io.helidon.microprofile.messaging.ChannelRouter.connect(ChannelRouter.java:90)
	at io.helidon.microprofile.messaging.MessagingCdiExtension.makeConnections(MessagingCdiExtension.java:187)

Steps to reproduce

@Test
void testEmptyValue() {
    org.eclipse.microprofile.config.Config config = ConfigProviderResolver.instance()
            .getBuilder()
            .withSources(MpConfigSources.create(Map.of("key", "")))
            .build();
    assertThat(config.getValue("key", String.class), is(""));
}
@romain-grecourt romain-grecourt added this to the 4.2.0 milestone Nov 19, 2024
@github-project-automation github-project-automation bot moved this to Triage in Backlog Nov 19, 2024
@m0mus m0mus added bug Something isn't working P2 labels Nov 21, 2024
@m0mus m0mus moved this from Triage to High priority in Backlog Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x bug Something isn't working config messaging Reactive Messaging microprofile P2
Projects
Status: High priority
Development

No branches or pull requests

3 participants