question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: ConfigProperty annotation on Map<String, String> field doesn't filter the configuration values, but populates all configuration entries in Map

See original GitHub issue

For a map configuration field like below, i expect the map to be populated with all configuration entries under configKey section, but the map is populated with all possible configuration entries - without any filtering.

    @Inject
    @ConfigProperty(name = "configKey")
    Map<String, String> configKeyMap;

Is this behaviour expected??? Is there a provision to filter out the configuration entries that just match to the name mentioned in the annotation?

If i understand correctly, filtration happens properly for List and Set field types (at-least as per the code for those branches). Why the behaviour is different for Map alone???

Environment Details

  • Helidon Version: 2.5.1
  • Helidon MP
  • JDK version: JDK 17
  • OS: Windows 11
  • Docker version (if applicable): NA

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tomas-langercommented, Jul 14, 2022

As this is not tested, we did not catch the difference in behavior. This was quite a big change (we had to switch away from using Helidon SE Config to using a full implementation of MP Config due to differences in handling environment variables), I have missed it when implementing it. We will get back to this and restore the original behavior

0reactions
tomas-langercommented, Jul 22, 2022

In the PR:

  • injection of map with a name defined in @ConfigProperty will inject only properties prefixed by that key, with the key removed from keys of the map
  • injection of map with default name will inject all properties available in config
  • I have added a test to verify this behavior
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug: ConfigProperty annotation on Map<String, String> field doesn't ...
Bug: ConfigProperty annotation on Map<String, String> field doesn't filter the configuration values, but populates all configuration entries in Map #4414.
Read more >
How to bind properties into a Map in Quarkus - Jose Carvajal
In Quarkus, the config values are injected via the @ConfigProperty annotation. But there is another annotation called @ConfigMapping to map more complex ...
Read more >
Configuration Reference Guide - Quarkus
In this reference guide we're going to describe various aspects of Quarkus configuration. A Quarkus application and Quarkus itself (core and extensions) are...
Read more >
Core Features - Spring
The properties that map to @ConfigurationProperties classes available in Spring Boot, which are configured through properties files, YAML files, ...
Read more >
Eager Initialization of Singletons - Micronaut Documentation
2, The @Get annotation is used to map the index method to all requests ... be populated with configuration values, the @ConfigurationBuilder annotation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found